From ce87beb55a2f0570018a8c9ce20d7088ac6a2fce Mon Sep 17 00:00:00 2001 From: alban Date: Mon, 2 Mar 2026 20:47:22 +0100 Subject: [PATCH] =?UTF-8?q?Ajouter=20du=20javascript=20Et=20ajout=20de=20l?= =?UTF-8?q?a=20gestion=20du=20fichier=20des=20utilisateurs=20ajout=C3=A9s?= =?UTF-8?q?=20en=20ligne?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...e_identifiants_mot_de_passe.cpython-37.pyc | Bin 736 -> 1014 bytes app.py | 9 +++--- mots_de_passe_identifiants.txt | 29 +++++++++++++----- repertoire_identifiants_mot_de_passe.py | 10 ++++-- templates/index.html | 12 +++++++- templates/result_add_user.html | 4 +-- 6 files changed, 46 insertions(+), 18 deletions(-) diff --git a/__pycache__/repertoire_identifiants_mot_de_passe.cpython-37.pyc b/__pycache__/repertoire_identifiants_mot_de_passe.cpython-37.pyc index e594e48e7e0f981fa4ace061399b154f77fe4659..b380801eb18bacd194ab623f08d885c3288e8a63 100644 GIT binary patch delta 609 zcmZ8eO=}cE5UuLz*_ljcSJ=RkgD3<{V64Wo*DS2)MltYM8; zdxqC+2j2DfVV`<^3eVsb7*773;qp4$x}_{e7Cy4=?Zmgdn#$4!N=}PxEG;i`ZLF`S zMQ#?qZ*C>r;w1Hp{IHaE{fUsJ$tQVM8imy0cTn+i6JI7lA;)H>q#HrUlmKIlDEc@+ z)uTG`)H)rDPj?2_=rk~gGpuRA6;1G#slnps)xDN!y+dgd*3#7#;wmS2p1O3i(Xmwd zWHi&V1$Bo&ASce$#_}`%I8hz}Lz3_v-G8rgBQN~V1>L9quNr1Tw3>Z-)a|!3H-p=1 vKv>dI?sqPF)J9o;P*sK6aG)bxD&Dxfw%vw1N0pcra+eXM?KNa!*zf!UyHJ6b delta 346 zcmYk0ze)o^5XSd!?s6tkG=jzTav+k@A_&@vU?W&u6E4i2EMD%y?#47JeSvV0%0kh` zckoHJ@+nd~cPVrSK6byI?>Dmze&pb~-;W5M^5avF*m`i1j_?HpsHQ1V6pI0S<-kF_ zh?F-D$kypVfQ|rpPm(Z|SH(0d)84Fd6Ht?RX01xN-@5@-I-TpRboG{=4P(SR@DC+e zJ@z!ZOPCkcT$NrfjdnQx59DcX0*ve=#G4N@fEL)R*Zk;qAH77jbkD6bUQDa1Fx@89 Z{QZl!pdDj8t6)*6%Vt?CP(pqf`~n-ZPrLvC diff --git a/app.py b/app.py index 20e44ec..e3e3f99 100644 --- a/app.py +++ b/app.py @@ -8,6 +8,7 @@ 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("/cherche") def cherche(): @@ -19,10 +20,10 @@ def form_add_user(): @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) + 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(): diff --git a/mots_de_passe_identifiants.txt b/mots_de_passe_identifiants.txt index c08e10b..b07ce51 100644 --- a/mots_de_passe_identifiants.txt +++ b/mots_de_passe_identifiants.txt @@ -1,10 +1,23 @@ -zebi;;prout -zebi;;prout -zebi;;prout -zebi;;prout zebi;;2 -zebi;;prout -zebi;;prout +lbn;;oui +passepartout;;olivier +test;;3 +test;;3 +zebi;;2 +zebi;;2 +zebi;;2 +zebi;;2 +zebi;;2 +zebi;;2 +opop;;popo +pipi;;caca +caca;;pipi +caca;;pipi +caca;;pipi +vent;;oluie +vent;;oluie +okko;;samourai +bleurj;;gh +bleurj;;gh +bleurj;;gh zebi;;2 -a;;a -user;;password diff --git a/repertoire_identifiants_mot_de_passe.py b/repertoire_identifiants_mot_de_passe.py index ec3ee38..68f6d18 100644 --- a/repertoire_identifiants_mot_de_passe.py +++ b/repertoire_identifiants_mot_de_passe.py @@ -1,10 +1,16 @@ _repertoire_identifiants_mot_de_passe= { "Alban": "mot_de_passe", } +def lecture(): + with open('mots_de_passe_identifiants.txt','r') as f: + for ligne in f: + ligne = ligne.replace("\n","") + Identifiant,mot_de_passe=list(ligne.split(";;")) + _repertoire_identifiants_mot_de_passe[Identifiant]=mot_de_passe + return _repertoire_identifiants_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: + if lecture().get(Identifiant, "Inconnu") == Mot_de_passe: return True else: return False diff --git a/templates/index.html b/templates/index.html index a2f553b..f37b95d 100644 --- a/templates/index.html +++ b/templates/index.html @@ -3,6 +3,14 @@ Logo + Accueil @@ -17,12 +25,14 @@
  • Rechercher un numéro
  • Ajouter un contact
  • -

    Ajouter un utilisateur

    + {% if Identifiant == "Alban" %} +

    Ajouter un utilisateur



    + {% endif %}

    Se connecter avec un autre identifiant

    \ No newline at end of file diff --git a/templates/result_add_user.html b/templates/result_add_user.html index ca3a87c..e6cfaf3 100644 --- a/templates/result_add_user.html +++ b/templates/result_add_user.html @@ -3,9 +3,7 @@ Utilisateur ajouté -

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

    -

    Retour accueil

    -

    ajouter un autre utilisateur

    +

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

    Se connecter avec un autre identifiant

    \ No newline at end of file