summaryrefslogtreecommitdiff
path: root/waterspout_radar/web.py
blob: 67ac4ca7c6a98e6e79d0f027b2b1232c0e5ec133 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import flask

from . import _storage

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>&Delta;Temp<th>Depth<th>SWI</tr>"
	for prediction in sorted(_storage.Storage(".waterspout/predictions.json"), key=lambda x: (x.time, x.swi)):
		body += f"<tr><td>{prediction.time}<td>{prediction.temperature_difference}<td>{prediction.convective_cloud_depth}<td>{prediction.swi}</tr>"
	body += "</table>"
	return body