Ajouter du javascript
Et ajout de la gestion du fichier des utilisateurs ajoutés en ligne
This commit is contained in:
Binary file not shown.
9
app.py
9
app.py
@@ -8,6 +8,7 @@ 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("user_search.html",display = "none")
|
||||||
|
return render_template("index.html", Identifiant="Alban")
|
||||||
|
|
||||||
@app.route("/cherche")
|
@app.route("/cherche")
|
||||||
def cherche():
|
def cherche():
|
||||||
@@ -19,10 +20,10 @@ def form_add_user():
|
|||||||
|
|
||||||
@app.route("/result_add_user", methods=["POST"])
|
@app.route("/result_add_user", methods=["POST"])
|
||||||
def result_add_user():
|
def result_add_user():
|
||||||
Identifiant = request.form.get("Identifiant", "").strip()
|
new_user = request.form.get("Identifiant", "").strip()
|
||||||
Mot_de_passe = request.form.get("Mot_de_passe", "").strip()
|
new_pasword = request.form.get("Mot_de_passe", "").strip()
|
||||||
add_user(Identifiant, Mot_de_passe)
|
add_user(new_user, new_pasword)
|
||||||
# return render_template("result_add_user.html", Identifiant=Identifiant, Mot_de_passe=Mot_de_passe)
|
return render_template("index.html", Identifiant="Alban", added_user=new_user)
|
||||||
|
|
||||||
@app.route("/ajout")
|
@app.route("/ajout")
|
||||||
def ajout():
|
def ajout():
|
||||||
|
|||||||
@@ -1,10 +1,23 @@
|
|||||||
zebi;;prout
|
|
||||||
zebi;;prout
|
|
||||||
zebi;;prout
|
|
||||||
zebi;;prout
|
|
||||||
zebi;;2
|
zebi;;2
|
||||||
zebi;;prout
|
lbn;;oui
|
||||||
zebi;;prout
|
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
|
zebi;;2
|
||||||
a;;a
|
|
||||||
user;;password
|
|
||||||
|
|||||||
@@ -1,10 +1,16 @@
|
|||||||
_repertoire_identifiants_mot_de_passe= {
|
_repertoire_identifiants_mot_de_passe= {
|
||||||
"Alban": "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:
|
def verif_user(Identifiant: str, Mot_de_passe: str) -> bool:
|
||||||
#
|
if lecture().get(Identifiant, "Inconnu") == Mot_de_passe:
|
||||||
if _repertoire_identifiants_mot_de_passe.get(Identifiant, "Inconnu") == Mot_de_passe:
|
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|||||||
@@ -3,6 +3,14 @@
|
|||||||
<head>
|
<head>
|
||||||
<img src="{{ url_for('static', filename='img/logo.jpg') }}" alt="Logo" width="160">
|
<img src="{{ url_for('static', filename='img/logo.jpg') }}" alt="Logo" width="160">
|
||||||
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
|
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
|
||||||
|
<script>
|
||||||
|
function added_user(Identifiant){
|
||||||
|
if (Identifiant){
|
||||||
|
alert("L'utilisateur " + Identifiant + " à été ajouté");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
added_user("{{added_user}}");
|
||||||
|
</script>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>Accueil</title>
|
<title>Accueil</title>
|
||||||
</head>
|
</head>
|
||||||
@@ -17,12 +25,14 @@
|
|||||||
<li><a href="{{ url_for('cherche') }}">Rechercher un numéro</a></li>
|
<li><a href="{{ url_for('cherche') }}">Rechercher un numéro</a></li>
|
||||||
<li><a href="{{ url_for('ajout') }}">Ajouter un contact</a></li>
|
<li><a href="{{ url_for('ajout') }}">Ajouter un contact</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
<h1>Ajouter un utilisateur</h1>
|
{% if Identifiant == "Alban" %}
|
||||||
|
<h1>Ajouter un utilisateur</h1>
|
||||||
<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 %}
|
||||||
<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>
|
||||||
@@ -3,9 +3,7 @@
|
|||||||
<head><meta charset="utf-8"><title>Utilisateur ajouté</title></head>
|
<head><meta charset="utf-8"><title>Utilisateur ajouté</title></head>
|
||||||
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
|
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
|
||||||
<body>
|
<body>
|
||||||
<h1>L'utilisateur {{Identifiant}} à été ajouté</h1>
|
<h1>L'utilisateur {{Identifiant}} à été ajouté</h1>
|
||||||
<p><a href="{{ url_for('index') }}">Retour accueil</a></p>
|
|
||||||
<p><a href="{{ url_for('add_user') }}">ajouter un autre utilisateur</a></p>
|
|
||||||
<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>
|
||||||
Reference in New Issue
Block a user