-
Notifications
You must be signed in to change notification settings - Fork 0
/
iphone_map.py
94 lines (68 loc) · 2.74 KB
/
iphone_map.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from mako.template import Template
class Map(webapp.RequestHandler):
def post(self):
lat = self.request.get('lat')
if not lat:
lat = 47.48414889179508
lng = self.request.get('lng')
if not lng:
lng = 19.059476852416992
template = Template(filename="iphone_map.html",
input_encoding='utf8',
output_encoding='utf8')
output = template.render(lat=lat,lng=lng)
self.response.out.write(output)
def get(self):
lat = 47.48414889179508
lng = 19.059476852416992
try:
if self.request.get('lat'):
lat = float(self.request.get('lat'))
if self.request.get('lng'):
lng = float(self.request.get('lng'))
except:
pass
template = Template(filename="iphone_map.html",
input_encoding='utf8',
output_encoding='utf8')
output = template.render(lat=lat,lng=lng)
self.response.out.write(output)
class EmbedMap(webapp.RequestHandler):
def get(self):
h = self.request.get('height')
w = self.request.get('width')
if not h or not w:
self.response.out.write("A helyes url: http://budapestcycletrack.appspot.com/embed_map?height=400&width=400")
return
template = Template(filename="embed_map.html",
input_encoding='utf8',
output_encoding='utf8')
output = template.render(width=w,height=h)
self.response.out.write(output)
class MapWithHeader(webapp.RequestHandler):
def get(self):
lat = 47.48414889179508
lng = 19.059476852416992
try:
if self.request.get('lat'):
lat = float(self.request.get('lat'))
if self.request.get('lng'):
lng = float(self.request.get('lng'))
except:
pass
template = Template(filename="iphone_map_with_header.html",
input_encoding='utf8',
output_encoding='utf8')
output = template.render(lat=lat,lng=lng)
self.response.out.write(output)
application = webapp.WSGIApplication(
[('/iphone_map', Map),
('/map', MapWithHeader),
('/embed_map', EmbedMap)],
debug=True)
def main():
run_wsgi_app(application)
if __name__ == "__main__":
main()