Merge branch 'master' of https://forge.chapril.org/CretinsMotorisesIngenieux/Marin
This commit is contained in:
commit
b929181dc5
4
app.py
4
app.py
@ -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()
|
||||
|
@ -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
|
||||
|
15
pages.py
15
pages.py
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user