-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmapotron.py
More file actions
50 lines (41 loc) · 1.26 KB
/
mapotron.py
File metadata and controls
50 lines (41 loc) · 1.26 KB
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
# A handler to render the index.html template for the MOL AngularJS SPA
from google.appengine.ext.webapp import template
from google.appengine.ext.webapp.util import run_wsgi_app
import logging
import os
import random
import ee_assets
import webapp2
import json
if 'SERVER_SOFTWARE' in os.environ:
PROD = not os.environ['SERVER_SOFTWARE'].startswith('Development')
else:
PROD = True
class BaseHandler(webapp2.RequestHandler):
def render_template(self, f, template_args):
path = os.path.join(os.path.dirname(__file__), "server_templates", f)
self.response.out.write(template.render(path, template_args))
def push_html(self, f):
path = os.path.join(os.path.dirname(__file__), "server_templates", f)
self.response.out.write(open(path, 'r').read())
class MapOTron(BaseHandler):
def get(self):
datasets = cache.get('earthenv-maps')
self.render_template(
'index.html',
{
"rand": "klsjdflkjs",
"collections" : datasets
})
def post(self):
self.push_html('index.html')
application = webapp2.WSGIApplication(
[
('/.*',MapOTron),
('/', MapOTron)
],
debug=True)
def main():
run_wsgi_app(application)
if __name__ == "__main__":
main()