-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
44 lines (34 loc) · 868 Bytes
/
app.py
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
37
38
39
40
41
42
43
44
from flask import Flask, render_template, redirect, request
import uuid
app = Flask(__name__)
# Store the TODOLIST items
items = [
{
"id": "0",
"title": "Example",
"description": "This is an example todo-list item",
"open": True,
},
]
def gen_uuid():
return uuid.uuid4()
@app.route("/")
def homepage():
return render_template("index.html", items=items)
@app.route("/check/<id>", methods=["GET"])
def check_item(id):
print(id)
for item in items:
if item["id"] == id:
item["open"] = False
break
return redirect("/")
@app.route("/add", methods=["POST"])
def add_item():
items.insert(0, {
"id": str(gen_uuid()),
"title": request.form["title"],
"description": request.form["description"],
"open": True,
})
return redirect("/")