diff options
author | ChatChimi <Pichue07@gmail.com> | 2020-04-18 14:23:26 +0200 |
---|---|---|
committer | ChatChimi <Pichue07@gmail.com> | 2020-04-18 14:23:26 +0200 |
commit | dc48cf7cbca435becc481c80214b320e78825eeb (patch) | |
tree | 79642f267de8d8a04655d1ce3670a9acaeffb081 /www/html | |
parent | 1323e52025bfd6f6e7584295619002a897c8da0c (diff) | |
parent | 4378405eea982cb3a42584d95767b5003675f611 (diff) |
Merge branch 'master' of https://github.com/clyhtsuriva/ATS-Project
Diffstat (limited to 'www/html')
-rwxr-xr-x | www/html/.htaccess | 5 | ||||
-rwxr-xr-x | www/html/fonctions.py | 23 | ||||
-rwxr-xr-x | www/html/index.html | 9 | ||||
-rwxr-xr-x | www/html/index.py | 39 | ||||
-rwxr-xr-x | www/html/init-bd.sql | 12 | ||||
-rwxr-xr-x | www/html/style.css | 12 | ||||
-rwxr-xr-x | www/html/test.html | 8 | ||||
-rwxr-xr-x | www/html/test.py | 11 |
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> +""")) |