Exemplo n.º 1
0
 def get(self):
   try:
       route = self.request.get('route')
       if route == "":
           raise ValueError
       directions = memcache.get(route)
       if directions is None:
           directions = scrapeDirection(self, route)
           memcache.add(route, directions, 60*60*24)
       self.response.out.write(jsonp(self.request, directions))
   except (ValueError, TypeError):
       self.response.out.write("<html><body><h4>Invalid Input</h4><p>route is a required input.<br /><i>Example: /direction?route=4</i></p></body></html>")
Exemplo n.º 2
0
 def get(self):
   try:
       route = self.request.get('route')
       direction = self.request.get('direction')
       if (route == "") or (direction == ""):
           raise ValueError
       memKey = route + "|" + direction
       stops = memcache.get(memKey)
       if stops is None:
           stops = scrapeStops(route, direction)
           memcache.add(memKey, stops, 60*60*24)
       self.response.out.write(jsonp(self.request, stops))
   except (ValueError, TypeError):
       self.response.out.write("<html><body><h4>Invalid Input</h4><p>route and direction are required inputs.<br /><i>Example: /direction?route=6&direction=4</i></p></body></html>")
Exemplo n.º 3
0
 def get(self):
     try:
         route = self.request.get('route')
         direction = self.request.get('direction')
         if (route == "") or (direction == ""):
             raise ValueError
         memKey = route + "|" + direction
         stops = memcache.get(memKey)
         if stops is None:
             stops = scrapeStops(route, direction)
             memcache.add(memKey, stops, 60 * 60 * 24)
         self.response.out.write(jsonp(self.request, stops))
     except (ValueError, TypeError):
         self.response.out.write(
             "<html><body><h4>Invalid Input</h4><p>route and direction are required inputs.<br /><i>Example: /direction?route=6&direction=4</i></p></body></html>"
         )
Exemplo n.º 4
0
 def get(self):
     routes = memcache.get("routes")
     if routes is None:
         routes = scrapeRoutes(self)
         memcache.add("routes", routes, 60 * 60 * 24)
     self.response.out.write(jsonp(self.request, routes))
Exemplo n.º 5
0
 def get(self):
     departures = scrapeDirection(self)
     self.response.out.write(jsonp(self.request, departures))
Exemplo n.º 6
0
 def get(self):
     departures = scrapeDirection(self)
     self.response.out.write(jsonp(self.request, departures))
Exemplo n.º 7
0
 def get(self):
   routes = memcache.get("routes")
   if routes is None:
       routes = scrapeRoutes(self)
       memcache.add("routes", routes, 60 * 60 * 24)
   self.response.out.write(jsonp(self.request, routes))