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():
return pages.main()
@app.route('/sauveteurs/<int:idsauveteur>')
def sauveteur(idsauveteur):
return pages.sauveteur(idsauveteur)
@app.errorhandler(404)
def error(e):
return pages.error()

View File

@ -1,8 +1,20 @@
### Fonctions communes
import sqlite3
def read(path):
# Retourne le contenu texte d'un fichier
f = open(path,'r')
result = f.read()
f.close()
return result
def ex_sql(db_name,request,replace=""):
conn = sqlite3.connect(db_name)
conn.row_factory=sqlite3.Row # La fonction retourne des dicos et pas des listes
cur = conn.cursor()
if not replace=="":
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
import definitions as lib
dbname = "site.db"
# Fonctions qui seront associées à des URLs
def main():
@ -8,3 +10,16 @@ def main():
def error():
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 {
font-family: arial;
}
h1 {
}
p {
h1, p {
padding: 20px;
}
table, tr, td {
border: 1px solid black;
border-collapse: collapse;
padding: 10px;
}
.table_key {
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" />
</head>
<body>
<header id="banner_index">
<center>
<div class="LOGO-DUO">
<img src="../static/icon.png" width="200" height="100">
<img src="../static/icon.png" width="250" height="125">
<h1>Sauveteurs du dunkerquois</h1>
</div>
</center>
</header>
<br>
<center>
<form method="get" >
<input type="text"
placeholder="Rechercher un sauveteur, un bateau, une personne sauvée..." size=40>

View File

@ -2,6 +2,8 @@
<!--- Variables
nom
prenom
date_naissance
date_deces
nb_sauvetages
nb_sauves
gratifications
@ -10,12 +12,24 @@ description
<head>
<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" />
</head>
<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>
<div class="flexbox">
<p>{{description}}</p>
<p class="right-align">
<table>
<tr>
<td class="table_key">Nom</td><td>{{nom}}</td>
@ -23,6 +37,12 @@ description
<tr>
<td class="table_key">Prénom</td><td>{{prenom}}</td>
</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>
<td class="table_key">Sauvetages effectués</td><td>{{nb_sauvetages}}</td>
</tr>
@ -33,6 +53,7 @@ description
<td class="table_key">Gratifications</td><td>{{gratifications}}</td>
</tr>
</table>
<p>{{description}}</p>
</p>
</div>
</body>
</html>