diff options
-rw-r--r-- | wk9/lect/froshims/app.py | 8 | ||||
-rw-r--r-- | wk9/lect/froshims/templates/index.html | 6 |
2 files changed, 8 insertions, 6 deletions
diff --git a/wk9/lect/froshims/app.py b/wk9/lect/froshims/app.py index 5d64a54..a60a291 100644 --- a/wk9/lect/froshims/app.py +++ b/wk9/lect/froshims/app.py @@ -2,13 +2,15 @@ from flask import Flask, render_template, request app = Flask(__name__) +SPORTS = ["Basketball", "Soccer", "Ultimate Frisbee"] + + @app.route("/") def index(): - return render_template("index.html") + return render_template("index.html", sports=SPORTS) @app.route("/register", methods=["POST"]) def register(): - - if not request.form.get("name") or not request.form.get("sport"): + if not request.form.get("name") or request.form.get("sport") not in SPORTS: return render_template("failure.html") return render_template("success.html") diff --git a/wk9/lect/froshims/templates/index.html b/wk9/lect/froshims/templates/index.html index d9920da..03eabb0 100644 --- a/wk9/lect/froshims/templates/index.html +++ b/wk9/lect/froshims/templates/index.html @@ -7,9 +7,9 @@ <input autocomplete="off" autofocus name="name" placeholder="Name" type="text"> <select name="sport"> <option disabled selected value="">Sport</option> - <option>Basketball</option> - <option>Soccer</option> - <option>Ultimate Frisbee</option> + {% for sport in sports %} + <option>{{sport}}</option> + {% endfor %} </select> <button type="submit">Register</button> </form> |