forked from CS3704-VT/top_five
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
36 lines (27 loc) · 1.02 KB
/
app.py
File metadata and controls
36 lines (27 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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)
def get_request(Request request):
if request.equals("GET"):
# Implement get functionality here
elif request.equals("POST"):
# Implement post functionality here
else:
return "GET and POST are the only valid requests."
if __name__ == "__main__":
app.run(debug=True)