U19: Spielstand speichern - Session, INSERT, UPDATE, Weiterspielen
This commit is contained in:
parent
dd2f96b731
commit
b968825aae
1 changed files with 13 additions and 1 deletions
14
app/app.py
14
app/app.py
|
|
@ -1,9 +1,10 @@
|
||||||
from flask import Flask, request
|
from flask import Flask, request, session, redirect
|
||||||
import html
|
import html
|
||||||
import sqlite3
|
import sqlite3
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
app.secret_key = "geheimnis-aus-dem-weltall"
|
||||||
DB_PATH = Path(__file__).with_name("adventure.db")
|
DB_PATH = Path(__file__).with_name("adventure.db")
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -185,6 +186,10 @@ def raum(id):
|
||||||
body = f"""
|
body = f"""
|
||||||
<h1>{html.escape(r['name'])}</h1>
|
<h1>{html.escape(r['name'])}</h1>
|
||||||
<p>{html.escape(r['beschreibung'])}</p>
|
<p>{html.escape(r['beschreibung'])}</p>
|
||||||
|
"""
|
||||||
|
if "spieler" in session:
|
||||||
|
body = body + '<p><small>Unterwegs als: ' + html.escape(session["spieler"]) + '</small></p>'
|
||||||
|
body = body + """
|
||||||
<div class="links">
|
<div class="links">
|
||||||
"""
|
"""
|
||||||
for a in ausgaenge:
|
for a in ausgaenge:
|
||||||
|
|
@ -193,5 +198,12 @@ def raum(id):
|
||||||
return render_page(html.escape(r["name"]), body)
|
return render_page(html.escape(r["name"]), body)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/reset")
|
||||||
|
@app.route("/app/reset")
|
||||||
|
def reset():
|
||||||
|
session.pop("spieler", None)
|
||||||
|
return redirect("/app/")
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app.run(host="0.0.0.0", port=9004)
|
app.run(host="0.0.0.0", port=9004)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue