Mise en place d'un système permettant de transmettre l'utilisateur logué de page en page

This commit is contained in:
Alban
2026-03-03 17:50:51 +01:00
parent ce87beb55a
commit 5c8902f354
6 changed files with 22 additions and 17 deletions

19
app.py
View File

@@ -7,9 +7,13 @@ app = Flask(__name__) # crée l'application Flask
@app.route("/") # URL racine : http://localhost:5000/ @app.route("/") # URL racine : http://localhost:5000/
def index(): def index():
return render_template("user_search.html",display = "none")
return render_template("index.html", Identifiant="Alban") return render_template("index.html", Identifiant="Alban")
@app.route("/index2/<Identifiant>") # URL racine : http://localhost:5000/
def index2(Identifiant):
return render_template("index.html", Identifiant=Identifiant)
@app.route("/cherche") @app.route("/cherche")
def cherche(): def cherche():
return render_template("cherche.html") return render_template("cherche.html")
@@ -57,18 +61,19 @@ def result_search():
else: else:
return render_template("user_search.html", display="visible") return render_template("user_search.html", display="visible")
@app.route("/NOTES") @app.route("/NOTES/<Identifiant>")
def NOTES(): def NOTES(Identifiant):
return render_template("NOTES.html") return render_template("NOTES.html", Identifiant=Identifiant)
@app.route("/heure") @app.route("/heure/<Identifiant>")
def heure(): def heure(Identifiant):
maintenant = datetime.now() maintenant = datetime.now()
return render_template( return render_template(
"heure.html", "heure.html",
h=maintenant.hour, h=maintenant.hour,
m=maintenant.minute, m=maintenant.minute,
s=maintenant.second s=maintenant.second,
Identifiant=Identifiant,
) )
@app.route("/formulaire") @app.route("/formulaire")

View File

@@ -23,7 +23,7 @@
</tbody> </tbody>
</table> </table>
<h2>#2.The Strongest Battlegrounds</h2> <h2>#2.The Strongest Battlegrounds</h2>
<img src="{{ url_for('static', filename='img/tSB_logo.jpg') }}" alt="Logo TSB" width="200"> <img src="{{ url_for('static', filename='img/TSB_logo.jpg') }}" alt="Logo TSB" width="200">
<h2>Phonk favoris</h2> <h2>Phonk favoris</h2>
<table> <table>
<tbody> <tbody>
@@ -40,7 +40,7 @@
</tbody> </tbody>
</table> </table>
<p><a href="{{ url_for('index') }}">Retour à l'accueil</a></p> <p><a href="{{ url_for('index') }}">Retour à l'accueil</a></p>
<p><a href="{{ url_for('heure') }}">Verifier l'heure</a></p> <p><a href="{{ url_for('heure',Identifiant=Identifiant) }}">Verifier l'heure</a></p>
<p><a href="{{ url_for('formulaire') }}">Aller au formulaire</a></p> <p><a href="{{ url_for('formulaire') }}">Aller au formulaire</a></p>
</body> </body>
</html> </html>

View File

@@ -4,10 +4,10 @@
<meta charset="utf-8"> <meta charset="utf-8">
<title>Heure</title> <title>Heure</title>
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}"> <link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
</head> </head>
<body> <body>
<h1>Page dynamique</h1> <h1>Page dynamique</h1>
<p>Il est {{ h }} h {{ m }} min {{ s }} s</p> <p>Il est {{ h }} h {{ m }} min {{ s }} s</p>
<p><a href="{{ url_for('index') }}">Retour</a></p> <p><a href="{{ url_for('index2', Identifiant=Identifiant) }}">Retour</a></p>
</body> </body>
</html> </html>

View File

@@ -17,8 +17,8 @@
<body> <body>
<h1>Mon site journal</h1> <h1>Mon site journal</h1>
<h2>Accueil</h2> <h2>Accueil</h2>
<p><a href="{{ url_for('NOTES') }}">Aller sur NOTES</a></p> <p><a href="{{ url_for('NOTES',Identifiant=Identifiant) }}">Aller sur NOTES</a></p>
<p><a href="{{ url_for('heure') }}">Verifier l'heure</a></p> <p><a href="{{ url_for('heure',Identifiant=Identifiant) }}">Verifier l'heure</a></p>
<p><a href="{{ url_for('formulaire') }}">Aller au formulaire</a></p> <p><a href="{{ url_for('formulaire') }}">Aller au formulaire</a></p>
<h3>Répertoire</h3> <h3>Répertoire</h3>
<ul> <ul>
@@ -30,9 +30,9 @@
<form action="{{ url_for('result_add_user') }}" method="post"> <form action="{{ url_for('result_add_user') }}" method="post">
<label>Identifiant : <input name="Identifiant" required></label><br> <label>Identifiant : <input name="Identifiant" required></label><br>
<label>Mot_de_passe : <input name="Mot_de_passe" required></label><br> <label>Mot_de_passe : <input name="Mot_de_passe" required></label><br>
<button type="submit">Ajouter</button> <button type="submit">Ajouter</button>
</form> </form>
{% endif %} {% endif %}
<p><a href="{{ url_for('user_search') }}">Se connecter avec un autre identifiant</a></p> <p><a href="{{ url_for('user_search') }}">Se connecter avec un autre identifiant</a></p>
</body> </body>
</html> </html>