version clé USB nommée Serveur_flask_v2 du 16 février 2026

This commit is contained in:
laurent
2026-05-08 12:41:00 +02:00
parent b71ae96310
commit 82765601b0
13 changed files with 121 additions and 213 deletions

112
app.py
View File

@@ -1,93 +1,19 @@
from flask import Flask, render_template, request
from datetime import datetime
from repertoire_web import ajouter, rechercher
from repertoire_identifiants_mot_de_passe import verif_user, add_user
app = Flask(__name__) # crée l'application Flask
@app.route("/") # URL racine : http://localhost:5000/
def index():
return render_template("user_search.html", display= "none")
#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")
def cherche():
return render_template("cherche.html")
@app.route("/form_add_user")
def form_add_user():
return render_template("add_user.html")
@app.route("/result_add_user", methods=["POST"])
def result_add_user():
new_user = request.form.get("Identifiant", "").strip()
new_pasword = request.form.get("Mot_de_passe", "").strip()
add_user(new_user, new_pasword)
return render_template("index.html", Identifiant="Alban", added_user=new_user)
@app.route("/ajout")
def ajout():
return render_template("ajout.html")
# Traitement des formulaires
@app.route("/resultat_recherche", methods=["POST"])
def resultat_recherche():
nom = request.form.get("nom", "").strip()
numero = rechercher(nom)
return render_template("resultat_recherche.html", nom=nom, numero=numero)
@app.route("/resultat_ajout", methods=["POST"])
def resultat_ajout():
nom = request.form.get("nom", "").strip()
numero = request.form.get("numero", "").strip()
ajouter(nom, numero)
return render_template("resultat_ajout.html", nom=nom, numero=numero)
@app.route("/user_search")
def user_search():
return render_template("user_search.html",display = "none")
@app.route("/result_search", methods=["POST"])
def result_search():
Identifiant = request.form.get("Identifiant", "").strip()
Mot_de_passe = request.form.get("Mot_de_passe", "").strip()
print([Identifiant,Mot_de_passe])
if verif_user(Identifiant, Mot_de_passe):
return render_template("index.html", Identifiant=Identifiant)
else:
return render_template("user_search.html", display="visible")
@app.route("/NOTES/<Identifiant>")
def NOTES(Identifiant):
return render_template("NOTES.html", Identifiant=Identifiant)
@app.route("/heure/<Identifiant>")
def heure(Identifiant):
maintenant = datetime.now()
return render_template(
"heure.html",
h=maintenant.hour,
m=maintenant.minute,
s=maintenant.second,
Identifiant=Identifiant,
)
@app.route("/formulaire")
def formulaire():
return render_template("formulaire.html")
@app.route("/resultat", methods=["POST"])
def resultat():
nom = request.form.get("nom", "").strip()
prenom = request.form.get("prenom", "").strip()
return render_template("resultat.html", nom=nom, prenom=prenom)
if __name__ == "__main__":
app.run() # lance le serveur (localhost:5000 par défaut)
# *************************************************************
# ************** SERVEUR WEB FLASK*****************************
# *************************************************************
from flask import Flask, render_template
app = Flask(__name__) # crée l'application Flask
@app.route("/") # URL racine : http://localhost:5000/
def index():
return render_template("index.html")
@app.route("/page_hopper")
def page_hopper():
return render_template("page_hopper.html")
if __name__ == "__main__":
app.run() # lance le serveur (localhost:5000 par défaut)