Marin/pages.py

51 lines
1.9 KiB
Python
Raw Normal View History

2021-12-02 19:41:51 +01:00
from flask import render_template
2021-12-02 19:05:44 +01:00
import definitions as lib
2021-12-03 01:08:46 +01:00
dbname = "site.db"
2021-12-02 19:41:51 +01:00
# Fonctions qui seront associées à des URLs
2021-12-02 19:05:44 +01:00
def main():
2021-12-02 20:17:23 +01:00
return render_template("index.html")
2021-12-02 20:14:13 +01:00
def error():
return render_template("error.html")
2021-12-03 01:08:46 +01:00
2021-12-03 02:05:05 +01:00
def bateau(idbateau):
dico = {}
dico["NomBateau"] = "Le Bateau"
dico["nom"] = "Le constructeur"
dico["Dimensions"] = 666
dico["DateInstallation"] = "Aujourd'hui"
dico["DateCondamnation"] = "Demain"
dico["ville"] = "ici"
dico["HistoireBateau"] = "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 bateau WHERE ship_id=?",(idbateau,))
if len(result)>=1:
result = result[0]
dico["nom"] = result["nom"]
print(result)
dico["Dimensions"] = result["dimension"]
dico["DateInstallation"] = result["date_naissance"]
dico["DateCondamnation"] = result["date_mort"]
return render_template("sauveteur.html",**dico)
else:
return error()
2021-12-03 01:08:46 +01:00
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."
2021-12-03 02:05:05 +01:00
result = lib.ex_sql(dbname,"SELECT * FROM sauveteur WHERE personal_id=?",(idsauveteur,))
if len(result)==1:
result = result[0]
dico["nom"] = result["nom"]
dico["prenom"] = result["prenom"]
return render_template("sauveteur.html",**dico)
else:
return error()