-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
67 lines (59 loc) · 1.18 KB
/
app.py
File metadata and controls
67 lines (59 loc) · 1.18 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from flask import Flask, render_template
import json
from firebase import firebase
app = Flask(__name__)
# STEP 1: Replace db_url string with your own URL to firebase database
db_url = "https://xxxx-xxxx-xxxx.firebaseio.com"
firebase = firebase.FirebaseApplication(db_url, authentication=None)
data = [{
"id": 1,
"name": "Eat Breakfast",
"minutes": 30
},
{
"id": 2,
"name": "Workout",
"minutes": 60
},
{
"id": 3,
"name": "Go to work",
"minutes": 30
},{
"id": 4,
"name": "Be lazy at work",
"minutes": 240
},
{
"id": 5,
"name": "Continue being lazy at work",
"minutes": 240
},
{
"id": 6,
"name": "Drive home",
"minutes": 30
},
{
"id": 7,
"name": "Work on interesting Sitepoint article",
"minutes": 30
},
{
"id": 8,
"name": "Sleep",
"minutes": 480
}]
result = firebase.put('/', 'test_data', data)
@app.route("/")
def index():
data = firebase.get('/test_data', None)
print(data)
return render_template("index.html", data=json.dumps(data))
@app.route("/load_products/", methods=["GET"])
def load_products():
# Use the global variable "data", defined above, in this example
print("at load products")
return json.dumps(data)
if __name__ == "__main__":
app.run(debug=True)