From 34a18b6eca9c3586c106efdebbd579c39e4006c6 Mon Sep 17 00:00:00 2001 From: Kevin Dungs Date: Mon, 17 Nov 2014 11:44:55 +0100 Subject: [PATCH 1/4] Add simple webservice. --- server.py | 27 +++++++++++++++++++++++++++ views/index.html | 47 +++++++++++++++++++++++++++++++++++++++++++++++ views/map.html | 24 ++++++++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100755 server.py create mode 100644 views/index.html create mode 100644 views/map.html 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..1a90a62 --- /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 word identified by three simple words. +

+

+ +

+

+ +

+
+ +
+ + diff --git a/views/map.html b/views/map.html new file mode 100644 index 0000000..345846d --- /dev/null +++ b/views/map.html @@ -0,0 +1,24 @@ + + + + + + + + +
+ + From 6f1a9824f0d70cf0ec46f2455df8b71736b52045 Mon Sep 17 00:00:00 2001 From: Kevin Dungs Date: Mon, 17 Nov 2014 14:04:38 +0100 Subject: [PATCH 2/4] Add section about webservice to README. --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 From d382b7bc96771e33c7aa69c38c2ba5d506a94720 Mon Sep 17 00:00:00 2001 From: Kevin Dungs Date: Mon, 17 Nov 2014 14:05:57 +0100 Subject: [PATCH 3/4] Adjust zoom. --- views/map.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/map.html b/views/map.html index 345846d..9557fda 100644 --- a/views/map.html +++ b/views/map.html @@ -10,7 +10,7 @@ function initialize() { var mapOptions = { center: { lat: {{ lat }}, lng: {{ lng }}}, - zoom: 8 + zoom: 14 }; var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions); From 3a0d9056609dc7f6bc93d08c0c127593887b6ca7 Mon Sep 17 00:00:00 2001 From: Kevin Dungs Date: Mon, 17 Nov 2014 14:45:04 +0100 Subject: [PATCH 4/4] Fix spelling. --- views/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/index.html b/views/index.html index 1a90a62..04fb4a8 100644 --- a/views/index.html +++ b/views/index.html @@ -16,7 +16,7 @@

These3Words Map

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