Skip to content
Snippets Groups Projects
Verified Commit c3f694d9 authored by Owen Graham's avatar Owen Graham
Browse files

Factor out assignments to `g`

parent 668ac649
No related branches found
No related tags found
No related merge requests found
...@@ -90,19 +90,19 @@ matplotlib.use('Agg') ...@@ -90,19 +90,19 @@ matplotlib.use('Agg')
@app.route('/') @app.route('/')
def home(): def home():
g.stations = read_stations() populate_g()
return render_template('index.html') return render_template('index.html')
@app.route('/overlay') @app.route('/overlay')
def overlay(): def overlay():
g.stations = read_stations() populate_g()
return render_template('overlay.html') return render_template('overlay.html')
@app.route('/boxplot') @app.route('/boxplot')
def boxplot(): def boxplot():
g.stations = read_stations() populate_g()
return render_template('boxplot.html') return render_template('boxplot.html')
...@@ -301,6 +301,11 @@ def savefig_response(fig): ...@@ -301,6 +301,11 @@ def savefig_response(fig):
return Response(buf.getvalue(), mimetype='image/png') return Response(buf.getvalue(), mimetype='image/png')
def populate_g():
"""Populate `g` with data for rendering page templates."""
g.stations = read_stations()
def read_stations(): def read_stations():
"""Read amrdcrecords.json.""" """Read amrdcrecords.json."""
with open('amrdcrecords.json') as f: with open('amrdcrecords.json') as f:
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment