This commit is contained in:
ElenaRJ 2026-06-17 16:21:07 +02:00
commit 5b622b5220

View file

@ -1,19 +1,19 @@
from flask import Flask, request, redirect from flask import Flask, request
app = Flask(__name__) app = Flask(__name__)
eintraege = [] # speichert die Nachrichten (im Arbeitsspeicher)
@app.route("/") @app.route("/pinnwand", methods=["GET", "POST"])
def hello(): def pinnwand():
return "Hallo aus meiner Flask-App! Willkommen in unseren Escape Room! Wuhuuuu es wird Gruselig"
@app.route("/frage", methods=["GET", "POST"])
def frage():
if request.method == "POST": if request.method == "POST":
if request.form["antwort"] == "8": eintraege.append(request.form["nachricht"])
return "Richtig!" return redirect("/app/pinnwand")
return "Leider falsch." liste = ""
return '<form method="post">Was ist 3 + 5? ' \ for e in eintraege:
'<input name="antwort"><button>OK</button></form>' liste = liste + "<li>" + e + "</li>"
return '<h1>Pinnwand</h1>' \
'<form method="post"><input name="nachricht">' \
'<button>Senden</button></form><ul>' + liste + '</ul>'
@app.route("/pinnwand", methods=["GET", "POST"]) @app.route("/pinnwand", methods=["GET", "POST"])
def pinnwand(): def pinnwand():
@ -28,4 +28,4 @@ def pinnwand():
'<button>Senden</button></form><ul>' + liste + '</ul>' '<button>Senden</button></form><ul>' + liste + '</ul>'
if __name__ == "__main__": if __name__ == "__main__":
app.run(host="0.0.0.0", port=9008) # 90 + Raumnummer (Wir: 08) app.run(host="0.0.0.0", port=9008)