From 07ceed5c7022da6233797c70954cf874239c88fa Mon Sep 17 00:00:00 2001 From: root Date: Sun, 30 Jan 2022 15:34:41 +0000 Subject: Add api integration --- main.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'main.py') diff --git a/main.py b/main.py index 58d8291..f42b319 100644 --- a/main.py +++ b/main.py @@ -4,6 +4,7 @@ import errors import sql import weather import time +import api from flask import Flask, render_template, redirect, url_for from threading import Thread @@ -36,6 +37,7 @@ 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), target_temp=boiler.target, forecast_temp=weather.temperature() @@ -77,6 +79,8 @@ def export(opt): "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: @@ -89,6 +93,8 @@ def webapp(): if __name__ == "__main__": + # Start the two main methods as threads + # Use of multithreaded processing t1 = Thread(target=webapp) t2 = Thread(target=updater) t1.start() -- cgit v1.2.3