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/
|
||||
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():
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -3,6 +3,14 @@
|
||||
<head>
|
||||
<img src="{{ url_for('static', filename='img/logo.jpg') }}" alt="Logo" width="160">
|
||||
<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">
|
||||
<title>Accueil</title>
|
||||
</head>
|
||||
@@ -17,12 +25,14 @@
|
||||
<li><a href="{{ url_for('cherche') }}">Rechercher un numéro</a></li>
|
||||
<li><a href="{{ url_for('ajout') }}">Ajouter un contact</a></li>
|
||||
</ul>
|
||||
<h1>Ajouter un utilisateur</h1>
|
||||
{% if Identifiant == "Alban" %}
|
||||
<h1>Ajouter un utilisateur</h1>
|
||||
<form action="{{ url_for('result_add_user') }}" method="post">
|
||||
<label>Identifiant : <input name="Identifiant" required></label><br>
|
||||
<label>Mot_de_passe : <input name="Mot_de_passe" required></label><br>
|
||||
<button type="submit">Ajouter</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
<p><a href="{{ url_for('user_search') }}">Se connecter avec un autre identifiant</a></p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -3,9 +3,7 @@
|
||||
<head><meta charset="utf-8"><title>Utilisateur ajouté</title></head>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
|
||||
<body>
|
||||
<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>
|
||||
<h1>L'utilisateur {{Identifiant}} à été ajouté</h1>
|
||||
<p><a href="{{ url_for('user_search') }}">Se connecter avec un autre identifiant</a></p>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user