-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
28 lines (18 loc) · 675 Bytes
/
Copy pathapp.py
File metadata and controls
28 lines (18 loc) · 675 Bytes
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
import io
from flask import Flask, Response, render_template, request
from aggregate import get_county_data
import seaborn as sns
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
from matplotlib.figure import Figure
app = Flask(__name__)
@app.route('/')
def index(name=None):
return render_template('index.html', name=name)
@app.route('/result', methods=['GET', 'POST'])
def result():
fig = get_county_data(request.form.get('state'), request.form.get('county'))
output = io.BytesIO()
FigureCanvas(fig).print_png(output)
return Response(output.getvalue(), mimetype='image/png')
if __name__ == '__main__':
app.run()