37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
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)
|