From fd4ab7ef4410a435f8c7339e111f791f5fdc9d0b Mon Sep 17 00:00:00 2001 From: Aki Date: Tue, 4 Apr 2023 23:37:03 +0200 Subject: Moved predictions page to templates --- waterspout_radar/templates/predictions.html | 19 +++++++++++++++++++ waterspout_radar/web.py | 17 ++--------------- 2 files changed, 21 insertions(+), 15 deletions(-) create mode 100644 waterspout_radar/templates/predictions.html diff --git a/waterspout_radar/templates/predictions.html b/waterspout_radar/templates/predictions.html new file mode 100644 index 0000000..1fa3840 --- /dev/null +++ b/waterspout_radar/templates/predictions.html @@ -0,0 +1,19 @@ + + + +Predictions +

Predictions

+
+ + +{% for p in predictions %} + + +{% endfor %} +
TimeLow CloudsΔTempCloud DepthWindSWI
{{ p.time }} +{{ "{:.0f}".format(p.low_clouds * 100) }}% +{{ "{:.1f}".format(p.temperature_difference) }} +{{ "{:.1f}".format(p.convective_cloud_depth) }} +{{ "{:.1f}".format(p.wind) }} +{{ "{:.1f}".format(p.swi) }} +
diff --git a/waterspout_radar/web.py b/waterspout_radar/web.py index a3ee09b..37905c3 100644 --- a/waterspout_radar/web.py +++ b/waterspout_radar/web.py @@ -7,18 +7,5 @@ app = flask.Flask(__name__) @app.route("/") def predictions(): - body = "Predictions" - body += "

Prediction


" - body += "" - body += "" - for prediction in sorted(_storage.Storage(".waterspout/predictions.json"), key=lambda x: (x.time, x.swi)): - body += "" - body += f"" - body += "
TimeLow CloudsΔTempDepthWindSWI
{prediction.time}" - body += f"{prediction.low_clouds}" - body += f"{prediction.temperature_difference}" - body += f"{prediction.convective_cloud_depth}" - body += f"{prediction.wind}" - body += f"{prediction.swi}" - body += "
" - return body + predictions = sorted(_storage.Storage(".waterspout/predictions.json"), key=lambda x: (x.time, x.swi)) + return flask.render_template("predictions.html", predictions=predictions) -- cgit v1.1