diff options
| author | root <root@turin.home> | 2022-01-30 15:34:41 +0000 |
|---|---|---|
| committer | root <root@turin.home> | 2022-01-30 15:34:41 +0000 |
| commit | 07ceed5c7022da6233797c70954cf874239c88fa (patch) | |
| tree | 5c12155538039c2e99ba3d2185c23861699329e7 | |
| parent | 455b655759db7ada3c7af28629cb8af95cecbaee (diff) | |
Add api integration
| -rw-r--r-- | api.py | 2 | ||||
| -rw-r--r-- | main.py | 6 |
2 files changed, 8 insertions, 0 deletions
@@ -1,3 +1,5 @@ +from __main__ import app + @app.route("/api/info") def api_info(): msg = """ @@ -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() |
