This commit is contained in:
batikano1 2021-12-03 01:12:13 +01:00
commit 61d0bb5f79
7 changed files with 108 additions and 16 deletions

4
app.py
View File

@ -10,6 +10,10 @@ app = Flask(__name__)
def main(): def main():
return pages.main() return pages.main()
@app.route('/sauveteurs/<int:idsauveteur>')
def sauveteur(idsauveteur):
return pages.sauveteur(idsauveteur)
@app.errorhandler(404) @app.errorhandler(404)
def error(e): def error(e):
return pages.error() return pages.error()

View File

@ -1,8 +1,20 @@
### Fonctions communes ### Fonctions communes
import sqlite3
def read(path): def ex_sql(db_name,request,replace=""):
# Retourne le contenu texte d'un fichier conn = sqlite3.connect(db_name)
f = open(path,'r') conn.row_factory=sqlite3.Row # La fonction retourne des dicos et pas des listes
result = f.read() cur = conn.cursor()
f.close() if not replace=="":
return result cur.execute(request,replace)
else:
cur.execute(request)
conn.commit()
a = None
if "SELECT" in request.upper():
a = cur.fetchall()
for i in range(len(a)):
a[i] = dict(a[i]) # Convertir les dicos sqlite3 en dico classiques python
cur.close()
conn.close()
return a

View File

@ -1,6 +1,8 @@
from flask import render_template from flask import render_template
import definitions as lib import definitions as lib
dbname = "site.db"
# Fonctions qui seront associées à des URLs # Fonctions qui seront associées à des URLs
def main(): def main():
@ -8,3 +10,16 @@ def main():
def error(): def error():
return render_template("error.html") return render_template("error.html")
def sauveteur(idsauveteur):
dico = {}
dico["nom"] = "John"
dico["prenom"] = "Doe"
dico["nb_sauvetages"] = 666
dico["nb_sauves"] = 666
dico["gratifications"] = 1
dico["description"] = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam at odio cursus, rutrum odio non, dignissim risus. Pellentesque non varius ante. Vivamus scelerisque pulvinar mauris, nec imperdiet ante mattis et."
result = lib.ex_sql(dbname,"SELECT * FROM sauveteur WHERE personal_id=?",(idsauveteur,))[0]
dico["nom"] = result["nom"]
dico["prenom"] = result["prenom"]
return render_template("sauveteur.html",**dico)

View File

@ -1,17 +1,55 @@
body { body {
font-family: arial;
} }
h1 { h1, p {
} padding: 20px;
p {
} }
table, tr, td { table, tr, td {
border: 1px solid black; border: 1px solid black;
border-collapse: collapse; border-collapse: collapse;
padding: 10px;
} }
.table_key { .table_key {
font-weight: bold; font-weight: bold;
} }
.flexbox {
display: flex;
}
#banner {
background-color: #dfcba8;
margin-left: calc(-50vw + 50%);
margin-right: calc(-50vw + 50%);
margin-top: calc(-50vw + 50%);
display: flex;
align-items: center;
padding-top: 5px;
padding-bottom: 5px;
}
#banner_index {
background-color: #dfcba8;
margin-left: calc(-50vw + 50%);
margin-right: calc(-50vw + 50%);
margin-top: calc(-50vw + 50%);
padding-top: 5px;
padding-bottom: 5px;
}
#logo_title {
font-weight: bold;
font-size: 30px;
}
.searchbar {
float: right;
padding-right: 20px;
}
.right-align {
margin-left: auto;
}

View File

@ -5,12 +5,14 @@
<link href="../static/style.css" rel="stylesheet" type="text/css" /> <link href="../static/style.css" rel="stylesheet" type="text/css" />
</head> </head>
<body> <body>
<header id="banner_index">
<center> <center>
<div class="LOGO-DUO"> <img src="../static/icon.png" width="250" height="125">
<img src="../static/icon.png" width="200" height="100">
<h1>Sauveteurs du dunkerquois</h1> <h1>Sauveteurs du dunkerquois</h1>
</div> </center>
</header>
<br> <br>
<center>
<form method="get" > <form method="get" >
<input type="text" <input type="text"
placeholder="Rechercher un sauveteur, un bateau, une personne sauvée..." size=40> placeholder="Rechercher un sauveteur, un bateau, une personne sauvée..." size=40>

View File

@ -2,6 +2,8 @@
<!--- Variables <!--- Variables
nom nom
prenom prenom
date_naissance
date_deces
nb_sauvetages nb_sauvetages
nb_sauves nb_sauves
gratifications gratifications
@ -10,12 +12,24 @@ description
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>{{nom}} {{prenom}} - Sauveuteur du dunkerquois</title> <title>{{nom}} {{prenom}} - Sauveuteurs du dunkerquois</title>
<link href="../static/style.css" rel="stylesheet" type="text/css" /> <link href="../static/style.css" rel="stylesheet" type="text/css" />
</head> </head>
<body> <body>
<img src="../static/icon.png"> <header id="banner">
<img src="../static/icon.png" width="150" height="75">
<span id="logo_title">Sauveuteurs du dunkerquois</span>
</header>
<br>
<a href="https://www.google.com/">Proposer une modification</a>
<form class="searchbar" method=get>
<input type="text" placeholder="Saisissez votre recherche..." size=20>
<input type="submit" value="Rechercher">
</form>
<h1>{{nom}} {{prenom}}</h1> <h1>{{nom}} {{prenom}}</h1>
<div class="flexbox">
<p>{{description}}</p>
<p class="right-align">
<table> <table>
<tr> <tr>
<td class="table_key">Nom</td><td>{{nom}}</td> <td class="table_key">Nom</td><td>{{nom}}</td>
@ -23,6 +37,12 @@ description
<tr> <tr>
<td class="table_key">Prénom</td><td>{{prenom}}</td> <td class="table_key">Prénom</td><td>{{prenom}}</td>
</tr> </tr>
<tr>
<td class="table_key">Naissance</td><td>{{date_naissance}}</td>
</tr>
<tr>
<td class="table_key">Décès</td><td>{{date_deces}}</td>
</tr>
<tr> <tr>
<td class="table_key">Sauvetages effectués</td><td>{{nb_sauvetages}}</td> <td class="table_key">Sauvetages effectués</td><td>{{nb_sauvetages}}</td>
</tr> </tr>
@ -33,6 +53,7 @@ description
<td class="table_key">Gratifications</td><td>{{gratifications}}</td> <td class="table_key">Gratifications</td><td>{{gratifications}}</td>
</tr> </tr>
</table> </table>
<p>{{description}}</p> </p>
</div>
</body> </body>
</html> </html>