This commit is contained in:
thunder down 2021-12-03 03:52:58 +01:00
commit a50dde5a68
8 changed files with 119 additions and 39 deletions

3
app.py
View File

@ -13,8 +13,7 @@ def main():
@app.route('/search', methods=['GET', 'POST'])
def search():
texte = request.form["search"]
print(texte)
return pages.main()
return pages.search(texte)
@app.route('/sauveteurs/<int:idsauveteur>')
@app.route('/sauveteur/<int:idsauveteur>')

View File

@ -1,5 +1,6 @@
from flask import render_template
import definitions as lib
from difflib import SequenceMatcher
dbname = "site.db"
@ -60,3 +61,30 @@ def sauveteur(idsauveteur):
return render_template("sauveteur.html",**dico)
else:
return error()
def search(texte):
sauveurs = lib.ex_sql(dbname,"SELECT * FROM sauveteur")
bateaux = lib.ex_sql(dbname,"SELECT * FROM bateau")
totals = sauveurs+bateaux
for i in totals:
i["score"] = 0
for key in i.keys():
if key!="score":
r = 1
if key=="nom":
r = 3
i["score"] += SequenceMatcher(None, texte, str(i[key])).ratio()*r
totals.sort(key=lambda x : x["score"])
totals.reverse()
totals = totals[:8]
results = []
for i in totals:
r = {}
if "ship_id" in i.keys():
r["lien"] = "/bateaux/"+str(i["ship_id"])
elif "personal_id" in i.keys():
r["lien"] = "/sauveteurs/"+str(i["personal_id"])
r["nom"] = i["nom"]
results.append(r)
return render_template("searchresults.html",liste=results)

View File

@ -45,6 +45,10 @@ table, tr, td {
font-size: 30px;
}
#searchresults {
width: 75%;
}
.searchbar {
float: right;
padding-right: 20px;

View File

@ -9,41 +9,54 @@ origine
histoire
!-->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>{{nom}}</title>
<link href="/static/style.css" rel="stylesheet" type="text/css">
<link rel="icon" type="image/png" href="../static/favicon.png" />
<title>{{nom}} - Sauveuteurs du dunkerquois</title>
<link href="../static/style.css" rel="stylesheet" type="text/css">
<link href="file:///C:/Users/rugja/Marin/templates/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<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}}}</h1>
<div class="flexbox">
<p>{{HistoireBateau}}</p>
<p class="right-align">
<table>
<tbody><tr>
<td>Nom</td>
<td class="table_key">Nom</td>
<td>{{NomBateau}}</td>
</tr>
<tr>
<td>Constructeur</td>
<td class="table_key">Constructeur</td>
<td>{{nom}}</td>
</tr>
<tr>
<td>Dimensions</td>
<td class="table_key">Dimensions</td>
<td>{{Dimensions}}</td>
</tr>
<tr>
<td>Installation</td>
<td>{{DateInstallation}}</td>
<td class="table_key">Installation</td>
<td>{{Date1}}</td>
</tr>
<tr>
<td>Condamnation</td>
<td>{{DateCondamnation}}</td>
<td class="table_key">Condamnation</td>
<td>{{Date2}}</td>
</tr>
<tr>
<th>Origine</th>
<th>{{ville}}</th>
<td class="table_key">Origine</td>
<td>{{ville}}</td>
</tr>
</tbody></table>
<p>
{{HistoireBateau}}
</p>
</body></html>

View File

@ -6,19 +6,29 @@ evenement
<!-- saved from url=(0055)file:///C:/Users/rugja/Marin/templates/bateau_temp.html -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>{{siecle}}</title>
<title>{{siecle}}- Sauveuteurs du dunkerquois</title>
<link href="../static/style.css" rel="stylesheet" type="text/css">
<link rel="icon" type="image/png" href="../static/favicon.png" />
</head>
<body>
<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>{{siecle}}</h1>
<div class="flexbox">
<table>
<tbody><tr>
<script> {% for i in range(Date) %}
{{ i }}
{% endfor %}
</script>
<td>Date</td>
<td class="table_key">Date</td>
<td>{{Annee}}</td>
</tr>
<tr>
@ -30,4 +40,4 @@ evenement
<td>{{Evenement}}</td>
</tr>
</tbody></table>
</body></html>
</body></html>

View File

@ -9,33 +9,43 @@ histoire
<!-- saved from url=(0055)file:///C:/Users/rugja/Marin/templates/bateau_temp.html -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>{{nom}}{{prenom}}</title>
<title>{{nom}}{{prenom}}- Sauveuteurs du dunkerquois</title>
<link href="../static/style.css" rel="stylesheet" type="text/css">
<link rel="icon" type="image/png" href="../static/favicon.png" />
</head>
<body>
<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>{{histoire}}</p>
<p class="right-align">
<table>
<tbody><tr>
<td>Nom</td>
<td class="table_key">Nom</td>
<td>{{nom}}</td>
</tr>
<tr>
<td>Prenom</td>
<td class="table_key">Prenom</td>
<td>{{prenom}}</td>
</tr>
<tr>
<td>Date</td>
<td class="table_key">Date</td>
<td>{{date}}</td>
</tr>
<tr>
<td>Place</td>
<td class="table_key">Place</td>
<td>{{place}}</td>
</tr>
</tbody></table>
<p>
{{Histoire}}
</p>
</body></html>
</body></html>

View File

@ -15,9 +15,15 @@
<input type="text" placeholder="Saisissez votre recherche..." size=20>
<input type="submit" value="Rechercher">
</form>
<script> {% for key, value in dres %}
{{<a href=}value{>}key{</a>}}
{% endfor %}
</script>
<h1>Résultats de la recherche :</h1>
<center>
<table id="searchresults">
{% for result in liste %}
<tr>
<td><a href="{{result.lien}}">{{result.nom}}</a></td>
</tr>
{% endfor %}
</table>
</center>
</body>
</html>

View File

@ -7,19 +7,29 @@ evenement
<!-- saved from url=(0055)file:///C:/Users/rugja/Marin/templates/bateau_temp.html -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>{{nom}}</title>
<title>{{nom}} - Sauveuteurs du dunkerquois</title>
<link href="../static/style.css" rel="stylesheet" type="text/css">
<link rel="icon" type="image/png" href="../static/favicon.png" />
</head>
<body>
<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}}</h1>
<div class="flexbox">
<table>
<tbody><tr>
<script> {% for i in range(Date) %}
{{ i }}
{% endfor %}
</script>
<td>Date</td>
<td class="table_key">Date</td>
<td>{{Annee}}</td>
</tr>
<tr>
@ -31,4 +41,4 @@ evenement
<td>{{Evenement}}</td>
</tr>
</tbody></table>
</body></html>
</body></html>