-
Notifications
You must be signed in to change notification settings - Fork 75
Expand file tree
/
Copy pathapp.py
More file actions
24 lines (20 loc) · 775 Bytes
/
app.py
File metadata and controls
24 lines (20 loc) · 775 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from flask import Flask, render_template, request, redirect
app = Flask(__name__)
# Simple in-memory storage for submissions
submissions = []
@app.route("/", methods=["GET", "POST"])
def home():
global submissions
if request.method == "POST":
# Get the category and top five items from the form
category = request.form.get("category", "").strip()
items = [
request.form.get(f"item{i}", "").strip() for i in range(1, 6)
]
# Validate that all inputs are filled
if category and all(items):
submissions.append({"category": category, "five": items})
return redirect("/")
return render_template("index.html", submissions=submissions)
if __name__ == "__main__":
app.run(debug=True)