these-3-words/app.py

32 lines
578 B
Python
Raw Normal View History

2014-11-17 10:44:55 +00:00
#!/usr/bin/env python
2014-11-17 14:44:39 +00:00
import bottle
2014-11-17 10:44:55 +00:00
from bottle import (
get,
run,
template
)
import thesethreewords as these
@get('/')
def index():
return template('index', err=None)
2014-11-17 14:44:39 +00:00
2014-11-17 10:44:55 +00:00
@get('/<threewords>')
def showMap(threewords):
try:
lat, lng = these.decode(threewords)
2014-11-17 15:59:10 +00:00
return template('map', lat=lat, lng=lng, threewords=threewords)
2014-11-17 10:44:55 +00:00
except:
return template('index',
err="Could not find location {}".format(threewords))
if __name__ == '__main__':
run(host='localhost', port=8080)
app = bottle.default_app()