Reformatage et suppression du .htaccess

This commit is contained in:
Valentin Moguérou 2023-05-17 00:03:11 +02:00
parent 7619f24fce
commit 22725ff897
3 changed files with 14 additions and 27 deletions

View File

@ -1,18 +0,0 @@
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# DO NOT REMOVE. CLOUDLINUX PASSENGER CONFIGURATION BEGIN
PassengerAppRoot "/home/wdgl1530/antinote.fr"
PassengerBaseURI "/"
PassengerPython "/home/wdgl1530/virtualenv/antinote.fr/3.10/bin/python"
PassengerAppLogFile "/home/wdgl1530/logs/passenger.log"
# DO NOT REMOVE. CLOUDLINUX PASSENGER CONFIGURATION END
# DO NOT REMOVE OR MODIFY. CLOUDLINUX ENV VARS CONFIGURATION BEGIN
<IfModule Litespeed>
</IfModule>
# DO NOT REMOVE OR MODIFY. CLOUDLINUX ENV VARS CONFIGURATION END

View File

@ -2,6 +2,7 @@ from uuid import uuid4
import mysql.connector
class Database:
def __init__(self, app):
self.db = mysql.connector.connect(
@ -32,13 +33,13 @@ class Database:
def check_connection(self, uuid):
self.cur.execute("DELETE FROM sessions WHERE expiry_date <= CURRENT_TIMESTAMP")
self.cur.execute("SELECT session_id FROM sessions WHERE session_id=%s", (uuid,))
result = self.cur.fetchall()
return result
return self.cur.fetchall()
def __del__(self):
self.cur.close()
self.db.close()
class User:
def __init__(self, user_id, username, nom, prenom, creation_date):
self.id = user_id
@ -47,6 +48,7 @@ class User:
self.prenom = prenom
self.creation_date = creation_date
class Session:
def __init__(self, db, uuid):
self.db = db
@ -55,14 +57,15 @@ class Session:
def get_user(self):
self.db.cur.execute("SELECT utilisateurs.user_id, username, nom, prenom, creation_date FROM utilisateurs "
"JOIN sessions ON utilisateurs.user_id=sessions.user_id WHERE session_id=%s", (self.uuid,))
"JOIN sessions ON utilisateurs.user_id=sessions.user_id WHERE session_id=%s", (self.uuid,))
result = self.db.cur.fetchall()
return User(*result[0])
def fetch_grades(self):
self.db.cur.execute("SELECT matieres.libelle, devoirs.libelle, date, coefficient, valeur, maximum FROM notes "
"JOIN devoirs ON notes.id_devoir=devoirs.id_devoir "
"JOIN matieres ON devoirs.id_matiere=matieres.id_matiere WHERE id_eleve=%s", (self.user.id,))
"JOIN devoirs ON notes.id_devoir=devoirs.id_devoir "
"JOIN matieres ON devoirs.id_matiere=matieres.id_matiere WHERE id_eleve=%s",
(self.user.id,))
result = self.db.cur.fetchall()
dico = {}

View File

@ -6,6 +6,7 @@ from flask import render_template, send_from_directory, request, session, redire
from .database import Session
def views(app, db):
def est_connecte():
return session.get("uuid") is not None and db.check_connection(session.get("uuid"))
@ -15,6 +16,7 @@ def views(app, db):
def wrapper(*args, **kwargs):
return func(*args, **kwargs) if est_connecte() else redirect("/login")
return wrapper
@app.route("/")
@login_required
def index():
@ -44,8 +46,8 @@ def views(app, db):
@login_required
def grades():
s = Session(db, session["uuid"])
grades = s.fetch_grades()
return render_template("grades.html", s=s, grades=grades)
g = s.fetch_grades()
return render_template("grades.html", s=s, grades=g)
@app.route("/timetable/")
@login_required