Formular in Rätselraum
This commit is contained in:
parent
c4281110f8
commit
774c7f56da
1 changed files with 16 additions and 3 deletions
19
app/app.py
19
app/app.py
|
|
@ -1,4 +1,4 @@
|
|||
from flask import Flask
|
||||
from flask import Flask, request
|
||||
import sqlite3
|
||||
|
||||
app = Flask(__name__)
|
||||
|
|
@ -12,10 +12,23 @@ def get_db():
|
|||
def start():
|
||||
return '<h1>Verlies</h1><a href="/app/raum/1">Abenteuer starten</a>'
|
||||
|
||||
@app.route("/raum/<int:id>")
|
||||
@app.route("/raum/<int:id>", methods=["GET", "POST"])
|
||||
def raum(id):
|
||||
db = get_db()
|
||||
r = db.execute("SELECT name, beschreibung FROM raeume WHERE id=?", (id,)).fetchone()
|
||||
r = db.execute("SELECT * FROM raeume WHERE id=?", (id,)).fetchone()
|
||||
|
||||
if r["raetsel_frage"]: # Rätselraum?
|
||||
if request.method == "POST":
|
||||
if request.form["antwort"].strip() == r["raetsel_antwort"]:
|
||||
db.close()
|
||||
return "<h1>Befreit!</h1>"
|
||||
db.close()
|
||||
return 'Leider falsch. <a href="/app/raum/' + str(id) + '">nochmal</a>'
|
||||
db.close()
|
||||
return "<h1>" + r["name"] + "</h1><p>" + r["beschreibung"] + "</p>" \
|
||||
+ '<form method="post">' + r["raetsel_frage"] \
|
||||
+ ' <input name="antwort"><button>OK</button></form>'
|
||||
|
||||
ausgaenge = db.execute(
|
||||
"SELECT richtung, nach_raum FROM ausgaenge WHERE von_raum=?", (id,)
|
||||
).fetchall()
|
||||
|
|
|
|||
Loading…
Reference in a new issue