diff options
Diffstat (limited to 'main.py')
| -rw-r--r-- | main.py | 18 |
1 files changed, 12 insertions, 6 deletions
@@ -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() |
