-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
35 lines (24 loc) · 873 Bytes
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import json
from flask import Flask, render_template
from packages.measurement_levels import MeasurementLevels
# setup minimal flask app
app = Flask(__name__)
# retrieve measurement stations
with open("measurement_stations.json", "r") as fp:
measurement_stations = json.load(fp)
# define welcome route
@app.route("/", methods=['GET', 'POST'])
def welcome():
msg = """
Hi, falls du nach den Pegelständen in und um Passau suchst, versuch es mal mit folgender URL:
http://localhost:5000/water_levels
"""
return msg
# define app route
@app.route("/water_levels", methods=['GET', 'POST'])
def measurement_levels():
# retrieve latest measurements
current_measurements = MeasurementLevels.fetch_all_stations(measurement_stations)
return render_template('index.html', cm=current_measurements)
if __name__ == "__main__":
app.run()