forked from coderspage/single-page-app-bottle
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
98 lines (41 loc) · 1.38 KB
/
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
from bottle import error, get, post, request, response, run, static_file, view
##############################
@get("/app.css")
def _():
return static_file("app.css", root=".")
##############################
@get("/spa.js")
def _():
return static_file("spa.js", root=".")
##############################
@get("/")
@view("index")
def _():
is_fetch = True if request.headers.get('From-Fetch') else False
return dict(title="Home page", is_fetch=is_fetch)
##############################
@get("/one")
@view("one")
def _():
is_fetch = True if request.headers.get('From-Fetch') else False
return dict(title="One is One", is_fetch=is_fetch)
##############################
@get("/two")
@view("two")
def _():
is_fetch = True if request.headers.get('From-Fetch') else False
return dict(title="Two is two", is_fetch=is_fetch)
##############################
@get("/items/<item_id>")
@view("item")
def _(item_id):
is_fetch = True if request.headers.get('From-Fetch') else False
page_title = f"Title Item {item_id}"
return dict(title=page_title, is_fetch=is_fetch, item_id=item_id)
##############################
@error(404)
@view("404")
def _(error):
return
##############################
run(host="127.0.0.1", port=80, debug=True, reloader=True)