these-3-words/app.py

33 lines
601 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
2014-11-18 06:22:28 +00:00
import api as json_api
2014-11-17 10:44:55 +00:00
@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()