diff options
Diffstat (limited to 'wk9/lect/hello')
-rw-r--r-- | wk9/lect/hello/app.py | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/wk9/lect/hello/app.py b/wk9/lect/hello/app.py index 988f13c..1c44a69 100644 --- a/wk9/lect/hello/app.py +++ b/wk9/lect/hello/app.py @@ -2,12 +2,9 @@ from flask import Flask, render_template, request app = Flask(__name__) -@app.route("/") +@app.route("/", methods=["GET", "POST"]) def index(): + if request.method == "POST": + name = request.form.get("name", "world") + return render_template("greet.html", name=name) return render_template("index.html") - - -@app.route("/greet", methods=["POST"]) -def greet(): - name = request.form.get("name", "world") - return render_template("greet.html", name=name) |