From 1ca19f43c131d77f18008dde867e76153288de38 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 3 Feb 2022 18:08:28 +0000 Subject: Exports and formatting. Reformatting. --- main.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'main.py') 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/") 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() -- cgit v1.2.3