commit 70a28837fe380e1b4a1afdee414457be7a8ef9d6 Author: alban Date: Mon Mar 2 14:42:04 2026 +0100 first commit diff --git a/TP_Flask_petit_serveur_web_NSI.pdf b/TP_Flask_petit_serveur_web_NSI.pdf new file mode 100644 index 0000000..40938e2 Binary files /dev/null and b/TP_Flask_petit_serveur_web_NSI.pdf differ diff --git a/__pycache__/repertoire_identifiants_mot_de_passe.cpython-311.pyc b/__pycache__/repertoire_identifiants_mot_de_passe.cpython-311.pyc new file mode 100644 index 0000000..48e917b Binary files /dev/null and b/__pycache__/repertoire_identifiants_mot_de_passe.cpython-311.pyc differ diff --git a/__pycache__/repertoire_identifiants_mot_de_passe.cpython-37.pyc b/__pycache__/repertoire_identifiants_mot_de_passe.cpython-37.pyc new file mode 100644 index 0000000..e594e48 Binary files /dev/null and b/__pycache__/repertoire_identifiants_mot_de_passe.cpython-37.pyc differ diff --git a/__pycache__/repertoire_web.cpython-311.pyc b/__pycache__/repertoire_web.cpython-311.pyc new file mode 100644 index 0000000..81f2fe2 Binary files /dev/null and b/__pycache__/repertoire_web.cpython-311.pyc differ diff --git a/__pycache__/repertoire_web.cpython-37.pyc b/__pycache__/repertoire_web.cpython-37.pyc new file mode 100644 index 0000000..57dfed0 Binary files /dev/null and b/__pycache__/repertoire_web.cpython-37.pyc differ diff --git a/app.py b/app.py new file mode 100644 index 0000000..20e44ec --- /dev/null +++ b/app.py @@ -0,0 +1,86 @@ +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") + +@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(): + Identifiant = request.form.get("Identifiant", "").strip() + Mot_de_passe = request.form.get("Mot_de_passe", "").strip() + add_user(Identifiant, Mot_de_passe) + # return render_template("result_add_user.html", Identifiant=Identifiant, Mot_de_passe=Mot_de_passe) + +@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") +def NOTES(): + return render_template("NOTES.html") + +@app.route("/heure") +def heure(): + maintenant = datetime.now() + return render_template( + "heure.html", + h=maintenant.hour, + m=maintenant.minute, + s=maintenant.second + ) + +@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) + + diff --git a/mots_de_passe_identifiants.txt b/mots_de_passe_identifiants.txt new file mode 100644 index 0000000..c08e10b --- /dev/null +++ b/mots_de_passe_identifiants.txt @@ -0,0 +1,10 @@ +zebi;;prout +zebi;;prout +zebi;;prout +zebi;;prout +zebi;;2 +zebi;;prout +zebi;;prout +zebi;;2 +a;;a +user;;password diff --git a/repertoire_identifiants_mot_de_passe.py b/repertoire_identifiants_mot_de_passe.py new file mode 100644 index 0000000..ec3ee38 --- /dev/null +++ b/repertoire_identifiants_mot_de_passe.py @@ -0,0 +1,18 @@ +_repertoire_identifiants_mot_de_passe= { + "Alban": "mot_de_passe", +} + +def verif_user(Identifiant: str, Mot_de_passe: str) -> bool: + # + if _repertoire_identifiants_mot_de_passe.get(Identifiant, "Inconnu") == Mot_de_passe: + return True + else: + return False + +def add_user(Identifiant: str, Mot_de_passe: str) -> None: + """Ajoute ou remplace une entrée du répertoire.""" + with open('mots_de_passe_identifiants.txt','a') as f : + f.write(Identifiant) + f.write(';;') + f.write(Mot_de_passe) + f.write("\n") diff --git a/repertoire_web.py b/repertoire_web.py new file mode 100644 index 0000000..6be8143 --- /dev/null +++ b/repertoire_web.py @@ -0,0 +1,14 @@ +# Créé par alban.beltran, le 16/02/2026 en Python 3.7 +# repertoire_web.py +_repertoire = { + "Alice": "0600000001", + "Bob": "0600000002" +} + +def rechercher(nom: str) -> str: + """Renvoie le numéro si le nom existe, sinon 'Inconnu'.""" + return _repertoire.get(nom, "Inconnu") + +def ajouter(nom: str, numero: str) -> None: + """Ajoute ou remplace une entrée du répertoire.""" + _repertoire[nom] = numero diff --git a/static/img/TSB_logo.jpg b/static/img/TSB_logo.jpg new file mode 100644 index 0000000..124bce7 Binary files /dev/null and b/static/img/TSB_logo.jpg differ diff --git a/static/img/logo.jpg b/static/img/logo.jpg new file mode 100644 index 0000000..0c1534f Binary files /dev/null and b/static/img/logo.jpg differ diff --git a/static/img/rivals_logo.jpg b/static/img/rivals_logo.jpg new file mode 100644 index 0000000..47054fe Binary files /dev/null and b/static/img/rivals_logo.jpg differ diff --git a/static/style.css b/static/style.css new file mode 100644 index 0000000..e053f0a --- /dev/null +++ b/static/style.css @@ -0,0 +1,33 @@ +.playwrite-cu-guides-regular { + font-family: "Playwrite CU Guides", cursive; + font-weight: 400; + font-style: normal; +} + + +.logo-style{ + border: solid 0px black; + background: silver; + text-align: center; + height: 94px; + width: 100px;} +body { + font-family: "Playwrite CU Guides", cursive; + background-color: #E9FAFC;} +h1 { + text-decoration: underline; + color: red;} + +h2 { + text-decoration: underline;} + +p { + color: blue;} + +table { + border-collapse: separate;} + +td { + border-style: inset; + border-color: #0000FF #00FFFF #00FFFF #0000FF;} + diff --git a/templates/NOTES.html b/templates/NOTES.html new file mode 100644 index 0000000..a1e9a2d --- /dev/null +++ b/templates/NOTES.html @@ -0,0 +1,46 @@ + + + + + + NOTES + + +

NOTES

+

Jeux favoris

+

#1.RIVALS

+ Logo Rivals + + + + + + + + + + + +

favorite main weapon: SNIPER

favorite secondary: daggers

favorite mele: schyte/katana

favorite utility: war horn/satchels

+

#2.The Strongest Battlegrounds

+ Logo TSB +

Phonk favoris

+ + + + + + + + + + + + + +

NO BATIDÃO

MENTE MÁ

AL NACER

PASSO BEM SOLTO

MONTAGEM RUGADA

MATADORA

+

Retour à l'accueil

+

Verifier l'heure

+

Aller au formulaire

+ + \ No newline at end of file diff --git a/templates/add_user.html b/templates/add_user.html new file mode 100644 index 0000000..e0ea87c --- /dev/null +++ b/templates/add_user.html @@ -0,0 +1,17 @@ + + + + + Add_user + + + +

Ajouter un utilisateur

+
+
+
+ +
+

Retour

+ + \ No newline at end of file diff --git a/templates/ajout.html b/templates/ajout.html new file mode 100644 index 0000000..4c3b709 --- /dev/null +++ b/templates/ajout.html @@ -0,0 +1,17 @@ + + + + + Ajout + + + +

Ajouter

+
+
+
+ +
+

Retour

+ + \ No newline at end of file diff --git a/templates/cherche.html b/templates/cherche.html new file mode 100644 index 0000000..1e5a91e --- /dev/null +++ b/templates/cherche.html @@ -0,0 +1,16 @@ + + + + + Recherche + + + +

Rechercher

+
+ + +
+

Retour

+ + \ No newline at end of file diff --git a/templates/formulaire.html b/templates/formulaire.html new file mode 100644 index 0000000..eb0c95d --- /dev/null +++ b/templates/formulaire.html @@ -0,0 +1,17 @@ + + + + + Formulaire + + + +

Formulaire

+
+
+
+ +
+

Retour

+ + \ No newline at end of file diff --git a/templates/heure.html b/templates/heure.html new file mode 100644 index 0000000..9627ced --- /dev/null +++ b/templates/heure.html @@ -0,0 +1,13 @@ + + + + + Heure + + + +

Page dynamique

+

Il est {{ h }} h {{ m }} min {{ s }} s

+

Retour

+ + \ No newline at end of file diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..a2f553b --- /dev/null +++ b/templates/index.html @@ -0,0 +1,28 @@ + + + + Logo + + + Accueil + + +

Mon site journal

+

Accueil

+

Aller sur NOTES

+

Verifier l'heure

+

Aller au formulaire

+

Répertoire

+ +

Ajouter un utilisateur

+
+
+
+ +
+

Se connecter avec un autre identifiant

+ + \ No newline at end of file diff --git a/templates/page2.html b/templates/page2.html new file mode 100644 index 0000000..33594f0 --- /dev/null +++ b/templates/page2.html @@ -0,0 +1,13 @@ + + + + + NOTES + + +

NOTES

+

Retour à l'accueil

+

Verifier l'heure

+

Aller au formulaire

+ + \ No newline at end of file diff --git a/templates/page_hopper.html b/templates/page_hopper.html new file mode 100644 index 0000000..b39a795 --- /dev/null +++ b/templates/page_hopper.html @@ -0,0 +1,19 @@ + + + + + + Site informaticiens + + +

+ Grace Hopper +

+ + Hopper + +
+ + Retour à l'accueuil + + \ No newline at end of file diff --git a/templates/page_vide.html b/templates/page_vide.html new file mode 100644 index 0000000..6dd9176 --- /dev/null +++ b/templates/page_vide.html @@ -0,0 +1,17 @@ + + + + + + Mon Titre + + + +

Ma page web

+ +

Mon pargraphe

+ + \ No newline at end of file diff --git a/templates/result_add_user.html b/templates/result_add_user.html new file mode 100644 index 0000000..ca3a87c --- /dev/null +++ b/templates/result_add_user.html @@ -0,0 +1,11 @@ + + + Utilisateur ajouté + + +

L'utilisateur {{Identifiant}} à été ajouté

+

Retour accueil

+

ajouter un autre utilisateur

+

Se connecter avec un autre identifiant

+ + \ No newline at end of file diff --git a/templates/resultat.html b/templates/resultat.html new file mode 100644 index 0000000..bd463c0 --- /dev/null +++ b/templates/resultat.html @@ -0,0 +1,12 @@ + + + + + Résultat + + +

Résultat

+

Bonjour {{ prenom }} {{ nom }} !

+

Revenir au formulaire

+ + \ No newline at end of file diff --git a/templates/resultat_ajout.html b/templates/resultat_ajout.html new file mode 100644 index 0000000..1c0a0a7 --- /dev/null +++ b/templates/resultat_ajout.html @@ -0,0 +1,9 @@ + + + Ajout OK + +

Contact ajouté

+

{{ nom }} → {{ numero }}

+

Retour accueil

+ + \ No newline at end of file diff --git a/templates/resultat_recherche.html b/templates/resultat_recherche.html new file mode 100644 index 0000000..9ebdc7e --- /dev/null +++ b/templates/resultat_recherche.html @@ -0,0 +1,11 @@ + + + Résultat + +

Résultat recherche

+

Nom : {{ nom }}

+

Numéro : {{ numero }}

+

Nouvelle recherche

+

Retour a l'acceuil

+ + \ No newline at end of file diff --git a/templates/script_mot_de_passe.js b/templates/script_mot_de_passe.js new file mode 100644 index 0000000..5246f04 --- /dev/null +++ b/templates/script_mot_de_passe.js @@ -0,0 +1,9 @@ +var msg1 = "Bonjour" +//Première boîte +alert(msg1); +//deuxième boîte +Identifiant = prompt("Identifiant","Identifiant"); +//Troisième boîte +Mot_de_passe = prompt("Mot de passe","mot de passe"); +var msg3 = "Bienvenue"+Identifiant +alert(msg3); \ No newline at end of file diff --git a/templates/user_search.html b/templates/user_search.html new file mode 100644 index 0000000..7d960ad --- /dev/null +++ b/templates/user_search.html @@ -0,0 +1,17 @@ + + + + + Recherche + + + +

VOUS N'AVEZ PAS DE COMPTE

+

Rechercher

+
+ + + +
+ + \ No newline at end of file