-
Notifications
You must be signed in to change notification settings - Fork 0
/
web.py
executable file
·37 lines (29 loc) · 845 Bytes
/
web.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
#!/usr/bin/env python
"""
LINEAGE J85480S1 CPL Monitor, Web interface module.
Usage:
python web.py
"""
import flask, reader
app = flask.Flask(__name__)
reader.init()
@app.route('/')
def read():
"""Returns the reader data"""
raw_values = (reader.read_latch()
if 'latch' in flask.request.args.keys()
else reader.read_raw())
return flask.jsonify(raw=raw_values,
human=reader.human(raw_values),
alarms=reader.alarms(raw_values))
# CLI invocation handler
if __name__ == '__main__':
try:
app.run(host='0.0.0.0',
port=5000,
debug=app.config.get('DEBUG'),
threaded=False,
use_reloader=True)
finally:
print 'Cleaning GPIO state...'
reader.cleanup()