version clé USB nommée Serveur_flask_v2 du 16 février 2026
92
app.py
@@ -1,93 +1,19 @@
|
|||||||
from flask import Flask, render_template, request
|
# *************************************************************
|
||||||
from datetime import datetime
|
# ************** SERVEUR WEB FLASK*****************************
|
||||||
from repertoire_web import ajouter, rechercher
|
# *************************************************************
|
||||||
from repertoire_identifiants_mot_de_passe import verif_user, add_user
|
|
||||||
|
from flask import Flask, render_template
|
||||||
|
|
||||||
app = Flask(__name__) # crée l'application Flask
|
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("index.html")
|
||||||
#return render_template("index.html", Identifiant="Alban")
|
|
||||||
|
|
||||||
@app.route("/index2/<Identifiant>") # URL racine : http://localhost:5000/
|
@app.route("/page_hopper")
|
||||||
def index2(Identifiant):
|
def page_hopper():
|
||||||
return render_template("index.html", Identifiant=Identifiant)
|
return render_template("page_hopper.html")
|
||||||
|
|
||||||
|
|
||||||
@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__":
|
if __name__ == "__main__":
|
||||||
app.run() # lance le serveur (localhost:5000 par défaut)
|
app.run() # lance le serveur (localhost:5000 par défaut)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
BIN
static/hopper_grace.jpg
Normal file
|
After Width: | Height: | Size: 19 KiB |
BIN
static/images/banane.png
Normal file
|
After Width: | Height: | Size: 89 KiB |
BIN
static/images/photo_informaticiens/JohnVonNeumann.jpg
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
static/images/photo_informaticiens/alan_turing.jpg
Normal file
|
After Width: | Height: | Size: 22 KiB |
BIN
static/images/photo_informaticiens/dennis_ritchie.jpg
Normal file
|
After Width: | Height: | Size: 30 KiB |
BIN
static/images/photo_informaticiens/hopper_grace.jpg
Normal file
|
After Width: | Height: | Size: 19 KiB |
BIN
static/images/photo_informaticiens/linus-torvalds.jpg
Normal file
|
After Width: | Height: | Size: 20 KiB |
BIN
static/images/photo_informaticiens/richard_stallman.jpg
Normal file
|
After Width: | Height: | Size: 61 KiB |
BIN
static/images/photo_informaticiens/tim-berners-lee.jpg
Normal file
|
After Width: | Height: | Size: 130 KiB |
@@ -1,33 +1,52 @@
|
|||||||
.playwrite-cu-guides-regular {
|
body{
|
||||||
font-family: "Playwrite CU Guides", cursive;
|
background-color:ivory;
|
||||||
font-weight: 400;
|
background-image: url(http://lorempixel.com/200/100/), url(http://lorempixel.com/400/200/);
|
||||||
font-style: normal;
|
background-size: cover;
|
||||||
|
background-repeat: repeat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.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{
|
h1{
|
||||||
text-decoration:underline;
|
text-decoration:underline;
|
||||||
color: red;}
|
color:red;
|
||||||
|
text-align:center;
|
||||||
|
font-family:Cursive;
|
||||||
|
}
|
||||||
|
|
||||||
h2 {
|
th{
|
||||||
text-decoration: underline;}
|
border : 2px solid black;
|
||||||
|
}
|
||||||
|
.nom{
|
||||||
|
text-align:left;
|
||||||
|
}
|
||||||
|
|
||||||
p {
|
.nom:hover{
|
||||||
color: blue;}
|
background-color:wheat;
|
||||||
|
color:green
|
||||||
|
}
|
||||||
|
.image{
|
||||||
|
max-width : 400px;
|
||||||
|
text-align:center;
|
||||||
|
border-color:silver;
|
||||||
|
border-width:10px;
|
||||||
|
border-style:double;
|
||||||
|
overflow: scroll;
|
||||||
|
resize:both;
|
||||||
|
margin:50px;
|
||||||
|
animation-name: cos;
|
||||||
|
animation-duration: 2s;
|
||||||
|
animation-timing-function:ease-in ;
|
||||||
|
animation-direction: alternate;
|
||||||
|
animation-iteration-count: 2;
|
||||||
|
border-radius: 10px 30px 30px 30px;
|
||||||
|
}
|
||||||
|
|
||||||
table {
|
@keyframes cos {
|
||||||
border-collapse: separate;}
|
0% {transform : rotate(-45deg); left: -50px}
|
||||||
|
100% {transform : rotate(45deg); left: 50px}
|
||||||
|
}
|
||||||
|
|
||||||
td {
|
.image:after {
|
||||||
border-style: inset;
|
content: "NSI" ;
|
||||||
border-color: #0000FF #00FFFF #00FFFF #0000FF;}
|
color: red;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,69 +1,32 @@
|
|||||||
<!doctype html>
|
<!DOCTYPE html>
|
||||||
<html lang = "fr">
|
<html lang = "fr">
|
||||||
<head>
|
<head>
|
||||||
<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>
|
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
|
||||||
<style>
|
<title> Site informaticiens </title>
|
||||||
.main{
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(1, 1fr) ;
|
|
||||||
}
|
|
||||||
.align_left {
|
|
||||||
grid-column: 1;
|
|
||||||
grid-row: 1 ;
|
|
||||||
/*
|
|
||||||
display: inline-block;
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
.align_right {
|
|
||||||
|
|
||||||
grid-column: 2;
|
|
||||||
grid-row: 1;
|
|
||||||
/*
|
|
||||||
position: relative;
|
|
||||||
top: 0px;
|
|
||||||
width: 40%;
|
|
||||||
float: right;
|
|
||||||
display: inline-block;
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<img src="{{ url_for('static', filename='img/logo.jpg') }}" style="display: block" alt="Logo" width="160">
|
<h1>
|
||||||
<div class= "main">
|
Quelsques grands noms de l'informagique !
|
||||||
<div class= "align_left">
|
</h1>
|
||||||
<h1>Mon site journal</h1>
|
|
||||||
<h2>Accueil</h2>
|
<table border="1">
|
||||||
<p><a href="{{ url_for('NOTES',Identifiant=Identifiant) }}">Aller sur NOTES</a></p>
|
<tbody>
|
||||||
<p><a href="{{ url_for('heure',Identifiant=Identifiant) }}">Verifier l'heure</a></p>
|
<tr>
|
||||||
<p><a href="{{ url_for('formulaire') }}">Aller au formulaire</a></p>
|
<td>
|
||||||
<h3>Répertoire</h3>
|
<a href="{{url_for('page_hopper')}}">Grace Hopper</a>
|
||||||
<ul>
|
</td>
|
||||||
<li><a href="{{ url_for('cherche') }}">Rechercher un numéro</a></li>
|
<td>L1 C2</td>
|
||||||
<li><a href="{{ url_for('ajout') }}">Ajouter un contact</a></li>
|
<td>L1 C3</td>
|
||||||
</ul>
|
|
||||||
</div>
|
</tr>
|
||||||
<div class= "align_right">
|
<tr>
|
||||||
{% if Identifiant == "Alban" %}
|
<td>L2 C1</td>
|
||||||
<h1>Ajouter un utilisateur</h1>
|
<td>L2 C2</td>
|
||||||
<form action="{{ url_for('result_add_user') }}" method="post">
|
<td>L2 C3</td>
|
||||||
<label>Identifiant : <input name="Identifiant" required></label><br>
|
</tr>
|
||||||
<label>Mot_de_passe : <input name="Mot_de_passe" required></label><br>
|
|
||||||
<button type="submit">Ajouter</button>
|
</tbody>
|
||||||
</form>
|
</table>
|
||||||
{% endif %}
|
|
||||||
<p><a href="{{ url_for('user_search') }}">Se connecter avec un autre identifiant</a></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
<html lang = "fr">
|
<html lang = "fr">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
|
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
|
||||||
<title> Site informaticiens </title>
|
<title> Site informaticiens </title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -10,10 +10,10 @@
|
|||||||
Grace Hopper
|
Grace Hopper
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
<img src= "images/photo_informaticiens/hopper_grace.jpg" alt="Hopper">
|
<img src= "{{ url_for( 'static', filename='images/photo_informaticiens/hopper_grace.jpg') }}" alt="Hopper">
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<a href="index.html">Retour à l'accueuil </a>
|
<a href="{{url_for('index')}}">Retour à l'accueuil </a>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||