generated from PdxCodeGuild/IntensivePythonFullStack
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtodo.py
42 lines (34 loc) · 933 Bytes
/
todo.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
import datetime
from jsondb import JsonDB
# db = JsonDB('database.json')
# db.load()
# x = db.get('x', 0)
# x += 1
# db.set('x', x)
# db.save()
from flask import Flask, render_template, request, redirect
app = Flask(__name__)
def get_temperature():
# request from weather api
return 63
texts = []
@app.route('/', methods=['GET', 'POST'])
def index():
db = JsonDB('db.json')
db.load()
list_of_dicts = db.get('todos', 0)
# list_of_dicts += 1
# y = db.set('x', list_of_dicts)
the_string = {'key': 'value'}
print(list_of_dicts)
# print(y)
if request.method == 'POST':
response = dict(request.form)
full_list = list_of_dicts.append(response)
print(list_of_dicts)
db.save()
print(response)
# db.set("todo-item", )
return redirect('/')
return render_template('todo.html', list_of_dicts=list_of_dicts)
app.run(debug=True)