all repos — iot-project @ 40bc072b8ba482d332c0c0e4d2f0b08dbf339345

bug fix, add sample template
Andronaco Marco marco.andronaco@olivetti.com
Thu, 21 Sep 2023 11:42:37 +0200
commit

40bc072b8ba482d332c0c0e4d2f0b08dbf339345

parent

9ce79df3e12ecf15bc627b3c3d3214b787188649

2 files changed, 6 insertions(+), 6 deletions(-)

jump to
A backend_iot/templates/index.html

@@ -0,0 +1,1 @@

+<h1>Hello world!</h1>
M backend_iot/views.pybackend_iot/views.py

@@ -1,16 +1,15 @@

from backend_iot import app -from backend_iot.db import getLatestRecord, addRecord -from backend_iot.api import get_aqi +from backend_iot.db import getLatestRecord, addRecord, get_aqi from flask import request, redirect, render_template, abort from datetime import datetime +current_latitude, current_longitude = 45.46437891252755, 7.872049153560152 + def update_record(record): record["latitude"] = current_latitude record["longitude"] = current_longitude record["timestamp"] = datetime.now() - -current_latitude = 30.3 -current_longitude = 40.4 + record["aqi"] = get_aqi(current_latitude, current_longitude) def latest_or_abort(): latest = getLatestRecord()

@@ -21,7 +20,7 @@

@app.route("/") def index_route(): if request.method == 'GET': - return latest_or_abort() + return render_template("index.html") form = request.form update_record(form)