aboutsummaryrefslogtreecommitdiff
path: root/www/html
diff options
context:
space:
mode:
authorChatChimi <Pichue07@gmail.com>2020-04-18 14:23:26 +0200
committerChatChimi <Pichue07@gmail.com>2020-04-18 14:23:26 +0200
commitdc48cf7cbca435becc481c80214b320e78825eeb (patch)
tree79642f267de8d8a04655d1ce3670a9acaeffb081 /www/html
parent1323e52025bfd6f6e7584295619002a897c8da0c (diff)
parent4378405eea982cb3a42584d95767b5003675f611 (diff)
Merge branch 'master' of https://github.com/clyhtsuriva/ATS-Project
Diffstat (limited to 'www/html')
-rwxr-xr-xwww/html/.htaccess5
-rwxr-xr-xwww/html/fonctions.py23
-rwxr-xr-xwww/html/index.html9
-rwxr-xr-xwww/html/index.py39
-rwxr-xr-xwww/html/init-bd.sql12
-rwxr-xr-xwww/html/style.css12
-rwxr-xr-xwww/html/test.html8
-rwxr-xr-xwww/html/test.py11
8 files changed, 119 insertions, 0 deletions
diff --git a/www/html/.htaccess b/www/html/.htaccess
new file mode 100755
index 0000000..d074f91
--- /dev/null
+++ b/www/html/.htaccess
@@ -0,0 +1,5 @@
+AuthType Basic
+AuthName "restricted area"
+AuthUserFile /var/www/.htpasswd
+require valid-user
+DirectoryIndex index.py
diff --git a/www/html/fonctions.py b/www/html/fonctions.py
new file mode 100755
index 0000000..c1566af
--- /dev/null
+++ b/www/html/fonctions.py
@@ -0,0 +1,23 @@
+#!/usr/bin/python3
+# -*- coding: utf-8 -*-
+import psycopg2
+
+def baseHTML(title,body):
+ content=("""<!DOCTYPE html>
+<html>
+ <head>
+ <title>"""+ title +"""</title>
+ <meta charset="UTF-8">
+ <link rel="stylesheet" type="text/css" href="style.css">
+ </head>
+ <body>"""+ body +"""</body>
+</html>
+
+ """)
+ return content
+
+
+def connexionBD():
+ connexion=psycopg2.connect ("host='localhost' dbname='atsdb' user='atsuser' password='123456'")
+ return connexion
+
diff --git a/www/html/index.html b/www/html/index.html
new file mode 100755
index 0000000..27f4dda
--- /dev/null
+++ b/www/html/index.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Just here to redirect you...</title>
+ <meta charset="UTF-8">
+ <meta http-equiv='refresh' content='0; URL=index.py'>
+ </head>
+ <body></body>
+</html>
diff --git a/www/html/index.py b/www/html/index.py
new file mode 100755
index 0000000..010ed2d
--- /dev/null
+++ b/www/html/index.py
@@ -0,0 +1,39 @@
+#!/usr/bin/python3
+# -*- coding: utf-8 -*-
+
+import mod_python
+from fonctions import baseHTML, connexionBD
+
+def index(req):
+ req.content_type="text/html"
+
+ content=str()
+
+#sql part
+ conn=connexionBD()
+ cur=conn.cursor()
+ sql="select * from trame;"
+ cur.execute(sql)
+ conn.commit()
+ data=cur.fetchall()
+ conn.close()
+#sql part
+
+ for i in data :
+ content+=("""<tr>""" +
+"""<td>""" + str(i[1]) + """</td>""" +
+"""<td>""" + str(i[2]) + """</td>""" +
+"""<td>""" + str(i[3]) + """</td>""" +
+"""<td>""" + str(i[4]) + """</td>""" +
+"""</tr>""")
+
+ req.write(baseHTML("ATS-Project","""
+<center><h1>ATS-Project</h1></center>
+<table>
+<tr><th>Heure</th><th>Protocole</th><th>Source</th><th>Destination</th></tr>
+"""
++ content +
+"""
+</table>
+""")) #tableheads to change so it takes the output of the select
+
diff --git a/www/html/init-bd.sql b/www/html/init-bd.sql
new file mode 100755
index 0000000..f1a4f2b
--- /dev/null
+++ b/www/html/init-bd.sql
@@ -0,0 +1,12 @@
+--Creation of the main table
+drop table if exists trame cascade;
+
+create table trame(
+ id_trame serial primary key,
+ heure varchar(100),
+ protocole varchar(100),
+ source varchar(100),
+ destination varchar(100)
+);
+
+
diff --git a/www/html/style.css b/www/html/style.css
new file mode 100755
index 0000000..6d0bd42
--- /dev/null
+++ b/www/html/style.css
@@ -0,0 +1,12 @@
+body {
+ background-color:#000000;
+}
+
+*{
+ color: white;
+}
+
+table,th,td {
+ border: 2px solid red;
+ text-align: center;
+}
diff --git a/www/html/test.html b/www/html/test.html
new file mode 100755
index 0000000..b789672
--- /dev/null
+++ b/www/html/test.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Test</title>
+ <meta charset="UTF-8">
+ </head>
+ <body>This is a test page</body>
+</html>
diff --git a/www/html/test.py b/www/html/test.py
new file mode 100755
index 0000000..6ff289c
--- /dev/null
+++ b/www/html/test.py
@@ -0,0 +1,11 @@
+#!/usr/bin/python3
+# -*- coding: utf-8 -*-
+
+import mod_python
+import fonctions
+
+def index(req):
+ req.content_type="text/html"
+ req.write(fonctions.baseHTML("Test","""
+This is a test page.</p>
+"""))