qsomap/web.py

29 lines
670 B
Python
Executable File

#!/usr/bin/env python3
from bottle import Bottle, request, response, template, static_file
from io import StringIO
import qsomap
app = application = Bottle()
@app.route('/render/map.svg')
def render():
svg_stream = StringIO()
qsomap.render(float(request.query.lat), float(request.query.lon), svg_stream, None)
response.content_type = 'image/svg+xml'
return svg_stream.getvalue()
@app.route('/')
@app.route('/index.html')
def index():
return template('index')
@app.route('/static/<filename:path>')
def send_static(filename):
return static_file(filename, root='./static')
if __name__ == "__main__":
app.run(host='localhost', port=8080)