diff --git a/README.md b/README.md index 8a752d0..7ab995d 100644 --- a/README.md +++ b/README.md @@ -78,10 +78,22 @@ have similar `these-3-words` hashes The other CERN site is [here][othercernmap]. + +webservice +========== + +The file `server.py` provides a tiny webservice that allows to display a +location given by three words on a Google Maps map. + +The server requires [bottle.py][bottlepy] to be installed. It can be run +locally by typing `./server.py` or `python server.py` respectively. + + this is a [@betatim][betatim] kind of idea [humanhash]: https://github.com/zacharyvoase/humanhash [geohash]: https://code.google.com/p/python-geohash/ [cernmap]: https://www.google.ch/maps/place/46%C2%B013'56.4%22N+6%C2%B003'19.5%22E/@46.2323356,6.0554194,17z/data=!3m1!4b1!4m2!3m1!1s0x0:0x0 [othercernmap]: https://www.google.ch/maps/place/46%C2%B015'24.5%22N+6%C2%B003'24.4%22E/@46.256811,6.056792,14z/data=!4m2!3m1!1s0x0:0x0 +[bottlepy]: http://bottlepy.org/ [betatim]: https://twitter.com/betatim diff --git a/server.py b/server.py new file mode 100755 index 0000000..97a7e62 --- /dev/null +++ b/server.py @@ -0,0 +1,27 @@ +#!/usr/bin/env python + +from bottle import ( + get, + run, + template +) + +import thesethreewords as these + + +@get('/') +def index(): + return template('index', err=None) + +@get('/') +def showMap(threewords): + try: + lat, lng = these.decode(threewords) + return template('map', lat=lat, lng=lng) + except: + return template('index', + err="Could not find location {}".format(threewords)) + + +if __name__ == '__main__': + run(host='localhost', port=8080) diff --git a/views/index.html b/views/index.html new file mode 100644 index 0000000..04fb4a8 --- /dev/null +++ b/views/index.html @@ -0,0 +1,47 @@ + + + + + + + these-3-words Map + + + + +
+ % if err: + + % end +
+

These3Words Map

+

+ Find a location anywhere in the world identified by three simple words. +

+

+ +

+

+ +

+
+ +
+ + diff --git a/views/map.html b/views/map.html new file mode 100644 index 0000000..9557fda --- /dev/null +++ b/views/map.html @@ -0,0 +1,24 @@ + + + + + + + + +
+ +