diff --git a/app.py b/app.py index 7c4ec81..025d143 100644 --- a/app.py +++ b/app.py @@ -10,6 +10,10 @@ app = Flask(__name__) def main(): return pages.main() +@app.route('/sauveteurs/') +def sauveteur(idsauveteur): + return pages.sauveteur(idsauveteur) + @app.errorhandler(404) def error(e): return pages.error() diff --git a/definitions.py b/definitions.py index 893429a..7aa5cf1 100644 --- a/definitions.py +++ b/definitions.py @@ -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 diff --git a/pages.py b/pages.py index af35d37..8135828 100644 --- a/pages.py +++ b/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) diff --git a/static/style.css b/static/style.css index b466fa2..84f2a2e 100644 --- a/static/style.css +++ b/static/style.css @@ -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; +} diff --git a/templates/bateau_temp.html b/templates/bateau.html similarity index 100% rename from templates/bateau_temp.html rename to templates/bateau.html diff --git a/templates/index.html b/templates/index.html index f88b0e2..0c244e7 100644 --- a/templates/index.html +++ b/templates/index.html @@ -5,12 +5,14 @@ +
+
diff --git a/templates/sauveteur.html b/templates/sauveteur.html index f10c532..fab59a9 100644 --- a/templates/sauveteur.html +++ b/templates/sauveteur.html @@ -2,6 +2,8 @@