Pinnwand
This commit is contained in:
parent
647fbe1719
commit
633b4fa7af
1 changed files with 16 additions and 4 deletions
18
app.py
18
app.py
|
|
@ -1,10 +1,11 @@
|
||||||
from flask import Flask, request
|
from flask import Flask, request, redirect
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
eintraege = []
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
def hello():
|
def hello():
|
||||||
return "Hallo aus meiner Flask-App!"
|
return "Willkommen in meiner Flask-App!"
|
||||||
|
|
||||||
@app.route("/frage", methods=["GET", "POST"])
|
@app.route("/frage", methods=["GET", "POST"])
|
||||||
def frage():
|
def frage():
|
||||||
|
|
@ -15,6 +16,17 @@ def frage():
|
||||||
return '<form method="post">Was ist 3 + 5? ' \
|
return '<form method="post">Was ist 3 + 5? ' \
|
||||||
'<input name="antwort"><button>OK</button></form>'
|
'<input name="antwort"><button>OK</button></form>'
|
||||||
|
|
||||||
|
@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 + "<li>" + e + "</li>"
|
||||||
|
return '<h1>Pinnwand</h1>' \
|
||||||
|
'<form method="post"><input name="nachricht">' \
|
||||||
|
'<button>Senden</button></form><ul>' + liste + '</ul>'
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app.run(host="0.0.0.0", port=9009)
|
app.run(host="0.0.0.0", port=9009)
|
||||||
|
|
||||||
Loading…
Reference in a new issue