-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrizzle.py
55 lines (43 loc) · 1.17 KB
/
drizzle.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
"""
A flask app for controlling relays, with a sprinkler flavour
"""
from json import load
from flask import Flask, redirect, request, url_for
app = Flask(__name__)
app.config.from_file("config.json", load=load)
app.logger.setLevel(app.config["LOG_LEVEL"])
@app.before_request
def log_request():
"""
Debug level output for every web request
"""
app.logger.debug(
" ".join(
[
str(x)
for x in [
request.remote_addr,
request.method,
request.path,
request.scheme,
]
]
)
)
with app.app_context():
from blueprints.schedule import schedule
from blueprints.sequence import sequence
from blueprints.zone import zone
app.register_blueprint(zone.zone)
app.register_blueprint(sequence.sequence)
app.register_blueprint(schedule.schedule)
@app.route("/")
def index():
"""
Redirect to index view
"""
return redirect(url_for("zone.zone_select"))
if __name__ == "__main__":
import bjoern
app.logger.info("Drizzle has started.")
bjoern.run(app, "0.0.0.0", app.config["APP_PORT"])