summaryrefslogtreecommitdiff
path: root/main.py
diff options
context:
space:
mode:
authorroot <root@turin.home>2022-02-03 18:08:28 +0000
committerroot <root@turin.home>2022-02-03 18:08:28 +0000
commit1ca19f43c131d77f18008dde867e76153288de38 (patch)
tree9423f24da815fee682b73189f03d18641c557b3e /main.py
parent333bdb9507ca82709d92fe8919a9b40fc02d7dc7 (diff)
Exports and formatting. Reformatting.
Diffstat (limited to 'main.py')
-rw-r--r--main.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/main.py b/main.py
index d6d6320..22cdbbf 100644
--- a/main.py
+++ b/main.py
@@ -35,14 +35,15 @@ else:
# Import API Script after Flask app and boiler classexists
import api
+
def main_page():
# paramaterised location of template in 'templates' folder
return render_template(
"main.html",
# Rounding value for user interface so number is not too long
- actual_temp=round(boiler.temperature,2),
+ actual_temp=round(boiler.temperature, 2),
target_temp=boiler.target,
- forecast_temp=weather.temperature()
+ forecast_temp=weather.temperature(),
)
@@ -72,18 +73,23 @@ def export_choice():
@app.route("/export/<opt>")
def export(opt):
- if opt == "txt":
- pass
- elif opt == "pdf":
- pass
+ # Defensive handling of input
+ if opt in ["temperature", "weather", "history", "schedule"]:
+ data = db.exec("select * from {}".format(opt))
+ o = ""
+ for i in data:
+ o += str(a) + "\n"
+ return o
else:
return render_template(
"error.html", error="Invalid export type"
)
+
# Methods that will run continously: the update script for the heating
# and the flask webapp
+
def updater():
while True:
boiler.update()