2019-04-22 07:57:20 +00:00
|
|
|
from flask import Flask, render_template, make_response, send_file, request
|
2019-05-18 11:47:28 +00:00
|
|
|
from map_generator 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)
|
2019-05-16 05:26:13 +00:00
|
|
|
elif t == 'bool':
|
|
|
|
return value == 'on'
|
2019-04-22 07:57:20 +00:00
|
|
|
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
|
2019-05-16 05:26:13 +00:00
|
|
|
|