diff options
author | Fudgerboy <91767657+Fudgerboy@users.noreply.github.com> | 2024-07-09 10:00:10 +0000 |
---|---|---|
committer | Fudgerboy <91767657+Fudgerboy@users.noreply.github.com> | 2024-07-09 10:00:10 +0000 |
commit | 66485a40fb0e7a3905241c1fcfe10a6feef51a3b (patch) | |
tree | 7e1c1ef5875e8fcb74d507fa1efe5d2f2f51ed38 /wk9 | |
parent | 6583298b160057ccecd7720ee663a90d3ec2921a (diff) |
Tue, Jul 9, 2024, 3:00 AM -07:00
Diffstat (limited to 'wk9')
-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> |