-
Notifications
You must be signed in to change notification settings - Fork 0
/
webapp.py
129 lines (96 loc) · 3.96 KB
/
webapp.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# WebApp using Bottle
import os
import bottle as bt
from bottle import route, run, template, request, get, post
import modularui as m
app = bt.Bottle()
genius = m.declaregenius(m.readgenius())
@app.route("/static/css/<filename>")
def stylesheets(filename):
return bt.static_file(filename, root='./static/css')
@app.route("/static/img/<filename>")
def stylesheets2(filename):
return bt.static_file(filename, root='./static/img')
@app.route("/static/fonts/<filename>")
def stylesheets3(filename):
return bt.static_file(filename, root='./static/fonts')
@app.route("/bar")
def bar_index():
return template("templates/bar", genius=m.declaregenius(m.readgenius()), \
to_print=m.displaymessage(), status=m.get_status(), apptitle=m.apptitle)
@app.route("/confirmd")
def quoted():
current_status = m.getcurrentstatus()
to_print = m.quote_display(current_status[0], current_status[1],
current_status[2], current_status[3], m.readgenius())
return template("templates/confirmd", genius=m.declaregenius(m.readgenius()), \
to_print=to_print, status=m.get_status(), apptitle=m.apptitle)
@app.route("/confirmb")
def quoteb():
current_status = m.getcurrentstatus()
to_print = m.quote_battery(current_status[0], current_status[1], m.readgenius())
return template("templates/confirmb", genius=m.declaregenius(m.readgenius()), \
to_print=to_print, status=m.get_status(), apptitle=m.apptitle)
@app.route("/d")
def action_d():
m.display.add()
return template("templates/bar", genius=m.declaregenius(m.readgenius()), \
to_print=m.displaymessage(), status=m.get_status(), apptitle=m.apptitle)
@app.route("/b")
def action_b():
m.battery.add()
return template("templates/bar", genius=m.declaregenius(m.readgenius()), \
to_print=m.displaymessage(), status=m.get_status(), apptitle=m.apptitle)
@app.route("/gr")
def gr_index():
return template("templates/gr", genius=m.declaregenius(m.readgenius()), \
to_print=m.displaymessage(), status=m.get_status(), apptitle=m.apptitle)
@app.route("/dc")
def action_dc():
if m.getcurrentstatus()[1] > 0:
m.calib.add()
return template("templates/gr", genius=m.declaregenius(m.readgenius()), \
to_print=m.display.remove(), status=m.get_status(), apptitle=m.apptitle)
@app.route("/df")
def action_df():
if m.getcurrentstatus()[2] > 0:
return template("templates/gr", genius=m.declaregenius(m.readgenius()), \
to_print=m.fail.add(), status=m.get_status(), apptitle=m.apptitle)
else:
return template("templates/gr", genius=m.declaregenius(m.readgenius()), \
to_print="Error!", status=m.get_status(), apptitle=m.apptitle)
@app.route("/nd")
def action_dc():
return template("templates/gr", genius=m.declaregenius(m.readgenius()), \
to_print=m.calib.remove(), status=m.get_status(), apptitle=m.apptitle)
@app.route("/nb")
def action_dc():
return template("templates/gr", genius=m.declaregenius(m.readgenius()), \
to_print=m.battery.remove(), status=m.get_status(), apptitle=m.apptitle)
@app.route("/grd")
def action_d():
return template("templates/gr", genius=m.declaregenius(m.readgenius()), \
to_print=m.display.add(), status=m.get_status(), apptitle=m.apptitle)
@app.route("/grb")
def action_b():
return template("templates/gr", genius=m.declaregenius(m.readgenius()), \
to_print=m.battery.add(), status=m.get_status(), apptitle=m.apptitle)
@app.route("/genius<num>")
def geniusnum(num):
return template("templates/gr", genius=m.setgenius(num), \
to_print=m.displaymessage(), status=m.get_status(), apptitle=m.apptitle)
#@app.route("/feedback")
@app.get("/feedback")
def form():
return template("templates/feedback", apptitle=m.apptitle)
@app.post("/feedback")
def submit():
m.sendfeedback(request.forms.get("feedbacktext"))
return template("templates/launch", genius=m.declaregenius(m.readgenius()), \
apptitle=m.apptitle)
@app.route("/")
def undeclared_index():
return template("templates/launch", genius=m.declaregenius(m.readgenius()), \
apptitle=m.apptitle)
bt.debug(True)
run(app, reloader=True, host="0.0.0.0", port=8080)