From 24ec731846916296273193906e929eebc7398c68 Mon Sep 17 00:00:00 2001 From: annika koenig Date: Wed, 1 Jul 2026 15:59:08 +0200 Subject: [PATCH] =?UTF-8?q?app=C3=A4nderung?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/app.py | 52 ++++++++++++++++++++++++---------------------------- 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/app/app.py b/app/app.py index 3bc428a..ea01830 100644 --- a/app/app.py +++ b/app/app.py @@ -1,36 +1,32 @@ -from flask import Flask, request, redirect +from flask import Flask +import sqlite3 app = Flask(__name__) +def get_db(): + db = sqlite3.connect("adventure.db") + db.row_factory = sqlite3.Row # Spalten per Name ansprechen + return db + @app.route("/") -#nachrichten -def hello(): - return "Hallo aus meiner Flask-App!" +def start(): + return '

Verlies

Abenteuer starten' -@app.route("/frage", methods=["GET", "POST"]) -def frage(): - if request.method == "POST": - if request.form["antwort"] == "8": - return "Richtig!" - return "Leider falsch." - return '
Was ist 3 + 5? ' \ - '
' +@app.route("/raum/") +def raum(id): + db = get_db() + r = db.execute("SELECT name, beschreibung FROM raeume WHERE id=?", (id,)).fetchone() + ausgaenge = db.execute( + "SELECT richtung, nach_raum FROM ausgaenge WHERE von_raum=?", (id,) + ).fetchall() + db.close() - -#pinnwand -eintraege = [] # speichert die Nachrichten (im Arbeitsspeicher) - -@app.route("/pinnwand", methods=["GET", "POST"]) -def pinnwand(): - if request.method == "POST": - eintraege.append(request.form["nachricht"]) - return redirect("/app/pinnwand") - liste = "" - for e in eintraege: - liste = liste + "
  • " + e + "
  • " - return '

    Pinnwand

    ' \ - '
    ' \ - '
    ' + html = "

    " + r["name"] + "

    " + html = html + "

    " + r["beschreibung"] + "

    " + for a in ausgaenge: + html = html + '' \ + + a["richtung"] + '   ' + return html if __name__ == "__main__": - app.run(host="0.0.0.0", port=9006) # 90 + Raumnummer \ No newline at end of file + app.run(host="0.0.0.0", port=9006) \ No newline at end of file