diff options
Diffstat (limited to 'waterspout_radar')
-rw-r--r-- | waterspout_radar/templates/predictions.html | 19 | ||||
-rw-r--r-- | waterspout_radar/web.py | 17 |
2 files changed, 21 insertions, 15 deletions
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 @@ +<!doctype html> +<html lang="en"> +<meta charset="utf-8"> +<title>Predictions</title> +<h1>Predictions</h1> +<hr> +<table> +<tr><th>Time<th>Low Clouds<th>ΔTemp<th>Cloud Depth<th>Wind<th>SWI</tr> +{% for p in predictions %} +<tr> +<td>{{ p.time }} +<td>{{ "{:.0f}".format(p.low_clouds * 100) }}% +<td>{{ "{:.1f}".format(p.temperature_difference) }} +<td>{{ "{:.1f}".format(p.convective_cloud_depth) }} +<td>{{ "{:.1f}".format(p.wind) }} +<td>{{ "{:.1f}".format(p.swi) }} +</tr> +{% endfor %} +</table> 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 = "<!doctype html><html lang='en'><meta charset='utf-8'><title>Predictions</title>" - body += "<h1>Prediction</h1><hr>" - body += "<table>" - body += "<tr><th>Time<th>Low Clouds<th>ΔTemp<th>Depth<th>Wind<th>SWI</tr>" - for prediction in sorted(_storage.Storage(".waterspout/predictions.json"), key=lambda x: (x.time, x.swi)): - body += "<tr>" - body += f"<td>{prediction.time}" - body += f"<td>{prediction.low_clouds}" - body += f"<td>{prediction.temperature_difference}" - body += f"<td>{prediction.convective_cloud_depth}" - body += f"<td>{prediction.wind}" - body += f"<td>{prediction.swi}" - body += "</tr>" - body += "</table>" - return body + predictions = sorted(_storage.Storage(".waterspout/predictions.json"), key=lambda x: (x.time, x.swi)) + return flask.render_template("predictions.html", predictions=predictions) |