qsomap/web.py

29 lines
670 B
Python
Raw Normal View History

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