2019-04-22 07:57:20 +00:00
|
|
|
from flask import Flask, render_template, make_response, send_file, request
|
|
|
|
from index import generate_map, parameters
|
2019-04-22 05:19:31 +00:00
|
|
|
|
|
|
|
app = Flask(__name__)
|
|
|
|
|
|
|
|
@app.route('/')
|
|
|
|
def index():
|
2019-04-22 07:57:20 +00:00
|
|
|
return render_template('index.html', parameters=parameters)
|
|
|
|
|
|
|
|
def parse(key, value):
|
|
|
|
t = parameters[key]['type']
|
|
|
|
if t == 'int':
|
|
|
|
return int(value)
|
|
|
|
elif t == 'float':
|
|
|
|
return float(value)
|
|
|
|
else:
|
|
|
|
return value
|
2019-04-22 05:19:31 +00:00
|
|
|
|
|
|
|
@app.route('/map')
|
|
|
|
def get_map():
|
2019-04-22 07:57:20 +00:00
|
|
|
params = { key: parse(key, request.args[key]) for key in request.args }
|
|
|
|
res = send_file(generate_map(**params), mimetype='image/png')
|
2019-04-22 05:19:31 +00:00
|
|
|
return res
|