From dc539fda0108dc724693fbdd7599bd86980f0de0 Mon Sep 17 00:00:00 2001 From: clyhtsuriva Date: Sun, 29 Mar 2020 19:53:38 +0200 Subject: some web changes --- www/html/.htaccess | 5 +++++ www/html/fonctions.py | 23 +++++++++++++++++++++++ www/html/index.html | 9 +++++++++ www/html/index.py | 39 +++++++++++++++++++++++++++++++++++++++ www/html/init-bd.sql | 12 ++++++++++++ www/html/style.css | 12 ++++++++++++ www/html/test.html | 8 ++++++++ www/html/test.py | 11 +++++++++++ 8 files changed, 119 insertions(+) create mode 100755 www/html/.htaccess create mode 100755 www/html/fonctions.py create mode 100755 www/html/index.html create mode 100755 www/html/index.py create mode 100755 www/html/init-bd.sql create mode 100755 www/html/style.css create mode 100755 www/html/test.html create mode 100755 www/html/test.py (limited to 'www/html') diff --git a/www/html/.htaccess b/www/html/.htaccess new file mode 100755 index 0000000..ff2ab4a --- /dev/null +++ b/www/html/.htaccess @@ -0,0 +1,5 @@ +AuthType Basic +AuthName "restricted area" +AuthUserFile /var/www/html/ATS-Project/web/.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=(""" + + + """+ title +""" + + + + """+ body +""" + + + """) + 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 @@ + + + + Just here to redirect you... + + + + + 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+=("""""" + +"""""" + str(i[1]) + """""" + +"""""" + str(i[2]) + """""" + +"""""" + str(i[3]) + """""" + +"""""" + str(i[4]) + """""" + +"""""") + + req.write(baseHTML("ATS-Project",""" +

ATS-Project

+ + +""" ++ content + +""" +
HeureProtocoleSourceDestination
+""")) #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 @@ + + + + Test + + + This is a test page + 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.

+""")) -- cgit v1.2.3