add Flask app (hello, frage, pinnwand)

This commit is contained in:
DylanBarnes 2026-06-21 15:06:58 +00:00
parent 4145d11432
commit 2b45e7e279
2 changed files with 40 additions and 0 deletions

3
app/.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
venv/
__pycache__/
*.pyc

37
app/app.py Normal file
View file

@ -0,0 +1,37 @@
from flask import Flask, request, redirect
app = Flask(__name__)
@app.route("/")
def hello():
return "Hallo aus meiner Flask-App!"
@app.route("/frage", methods=["GET", "POST"])
def frage():
if request.method == "POST":
if request.form.get("antwort") == "8":
return "Richtig!"
return "Leider falsch."
return '<form method="post">Was ist 3 + 5? ' \
'<input name="antwort"><button>OK</button></form>'
# Pinnwand (in-memory)
eintraege = []
@app.route("/pinnwand", methods=["GET", "POST"])
def pinnwand():
if request.method == "POST":
nachricht = request.form.get("nachricht", "").strip()
if nachricht:
eintraege.append(nachricht)
return redirect("/app/pinnwand")
liste = ""
for e in eintraege:
liste = liste + "<li>" + e + "</li>"
return '<h1>Pinnwand</h1>' \
'<form method="post"><input name="nachricht">' \
'<button>Senden</button></form><ul>' + liste + '</ul>'
if __name__ == "__main__":
# Assuming room number 04 based on home directory isa4 -> port 9004
app.run(host="0.0.0.0", port=9004)