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
+
+Heure | Protocole | Source | Destination |
+"""
++ content +
+"""
+
+""")) #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
From 4378405eea982cb3a42584d95767b5003675f611 Mon Sep 17 00:00:00 2001
From: clyhtsuriva
Date: Sun, 29 Mar 2020 20:41:49 +0200
Subject: debugging and apache help
---
www/apache-modified/apache2.conf | 3 +++
www/apache-modified/help.txt | 13 +++++++++++++
www/html/.htaccess | 2 +-
3 files changed, 17 insertions(+), 1 deletion(-)
create mode 100644 www/apache-modified/help.txt
(limited to 'www/html')
diff --git a/www/apache-modified/apache2.conf b/www/apache-modified/apache2.conf
index c1b9b89..3bdb180 100755
--- a/www/apache-modified/apache2.conf
+++ b/www/apache-modified/apache2.conf
@@ -171,6 +171,9 @@ Include ports.conf
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
+ AddHandler mod_python .py
+ PythonHandler mod_python.publisher
+ PythonDebug On
#
diff --git a/www/apache-modified/help.txt b/www/apache-modified/help.txt
new file mode 100644
index 0000000..80b10ff
--- /dev/null
+++ b/www/apache-modified/help.txt
@@ -0,0 +1,13 @@
+#pour felix
+
+#first, you have to install apache2 (server), mod_python (to build html via python) and python-psycopg2 (to use psql) :
+apt install apache2 libapache2-mod-python python-psycopg2
+
+#replace the actual /var/www by our ATS-Project/www
+cp -r /root/ATS-Project/www /var/
+
+#give the x rights on the .py files
+chmod +x /var/www/html *.py
+
+#replace the actual /etc/apache2/apache2.conf by our ATS-Project/www/apache-modified/apache2.conf
+cp -r ...
diff --git a/www/html/.htaccess b/www/html/.htaccess
index ff2ab4a..d074f91 100755
--- a/www/html/.htaccess
+++ b/www/html/.htaccess
@@ -1,5 +1,5 @@
AuthType Basic
AuthName "restricted area"
-AuthUserFile /var/www/html/ATS-Project/web/.htpasswd
+AuthUserFile /var/www/.htpasswd
require valid-user
DirectoryIndex index.py
--
cgit v1.2.3