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
|
||||
from repertoire_web import ajouter, rechercher
|
||||
from repertoire_identifiants_mot_de_passe import verif_user, add_user
|
||||
# *************************************************************
|
||||
# ************** SERVEUR WEB FLASK*****************************
|
||||
# *************************************************************
|
||||
|
||||
from flask import Flask, render_template
|
||||
|
||||
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")
|
||||
return render_template("index.html")
|
||||
|
||||
@app.route("/index2/<Identifiant>") # URL racine : http://localhost:5000/
|
||||
def index2(Identifiant):
|
||||
return render_template("index.html", Identifiant=Identifiant)
|
||||
@app.route("/page_hopper")
|
||||
def page_hopper():
|
||||
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__":
|
||||
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 {
|
||||
font-family: "Playwrite CU Guides", cursive;
|
||||
font-weight: 400;
|
||||
font-style: normal;
|
||||
body{
|
||||
background-color:ivory;
|
||||
background-image: url(http://lorempixel.com/200/100/), url(http://lorempixel.com/400/200/);
|
||||
background-size: cover;
|
||||
background-repeat: repeat;
|
||||
}
|
||||
|
||||
h1{
|
||||
text-decoration:underline;
|
||||
color:red;
|
||||
text-align:center;
|
||||
font-family:Cursive;
|
||||
}
|
||||
|
||||
.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;}
|
||||
th{
|
||||
border : 2px solid black;
|
||||
}
|
||||
.nom{
|
||||
text-align:left;
|
||||
}
|
||||
|
||||
h2 {
|
||||
text-decoration: underline;}
|
||||
.nom:hover{
|
||||
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;
|
||||
}
|
||||
|
||||
p {
|
||||
color: blue;}
|
||||
@keyframes cos {
|
||||
0% {transform : rotate(-45deg); left: -50px}
|
||||
100% {transform : rotate(45deg); left: 50px}
|
||||
}
|
||||
|
||||
table {
|
||||
border-collapse: separate;}
|
||||
|
||||
td {
|
||||
border-style: inset;
|
||||
border-color: #0000FF #00FFFF #00FFFF #0000FF;}
|
||||
.image:after {
|
||||
content: "NSI" ;
|
||||
color: red;
|
||||
}
|
||||
|
||||
@@ -1,69 +1,32 @@
|
||||
<!doctype html>
|
||||
<html lang="fr">
|
||||
<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">
|
||||
<title>Accueil</title>
|
||||
<style>
|
||||
.main{
|
||||
display: grid;
|
||||
grid-template-columns: repeat(1, 1fr) ;
|
||||
}
|
||||
.align_left {
|
||||
grid-column: 1;
|
||||
grid-row: 1 ;
|
||||
/*
|
||||
display: inline-block;
|
||||
*/
|
||||
}
|
||||
.align_right {
|
||||
<!DOCTYPE html>
|
||||
<html lang = "fr">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
|
||||
<title> Site informaticiens </title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>
|
||||
Quelsques grands noms de l'informagique !
|
||||
</h1>
|
||||
|
||||
grid-column: 2;
|
||||
grid-row: 1;
|
||||
/*
|
||||
position: relative;
|
||||
top: 0px;
|
||||
width: 40%;
|
||||
float: right;
|
||||
display: inline-block;
|
||||
*/
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<img src="{{ url_for('static', filename='img/logo.jpg') }}" style="display: block" alt="Logo" width="160">
|
||||
<div class= "main">
|
||||
<div class= "align_left">
|
||||
<h1>Mon site journal</h1>
|
||||
<h2>Accueil</h2>
|
||||
<p><a href="{{ url_for('NOTES',Identifiant=Identifiant) }}">Aller sur NOTES</a></p>
|
||||
<p><a href="{{ url_for('heure',Identifiant=Identifiant) }}">Verifier l'heure</a></p>
|
||||
<p><a href="{{ url_for('formulaire') }}">Aller au formulaire</a></p>
|
||||
<h3>Répertoire</h3>
|
||||
<ul>
|
||||
<li><a href="{{ url_for('cherche') }}">Rechercher un numéro</a></li>
|
||||
<li><a href="{{ url_for('ajout') }}">Ajouter un contact</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class= "align_right">
|
||||
{% 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>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<table border="1">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="{{url_for('page_hopper')}}">Grace Hopper</a>
|
||||
</td>
|
||||
<td>L1 C2</td>
|
||||
<td>L1 C3</td>
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td>L2 C1</td>
|
||||
<td>L2 C2</td>
|
||||
<td>L2 C3</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
@@ -2,7 +2,7 @@
|
||||
<html lang = "fr">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
|
||||
<title> Site informaticiens </title>
|
||||
</head>
|
||||
<body>
|
||||
@@ -10,10 +10,10 @@
|
||||
Grace Hopper
|
||||
</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>
|
||||
|
||||
<a href="index.html">Retour à l'accueuil </a>
|
||||
<a href="{{url_for('index')}}">Retour à l'accueuil </a>
|
||||
</body>
|
||||
</html>
|
||||