Example #1
0
 def GET(self):
     """Add your own key in server config"""
     web.header('Content-Type', 'application/json')
     i = web.input(key="")
     if i.key == server['secret']:
         db = Db(server['paths']['db'])
         return db.get('analytics')
Example #2
0
    def GET (self, version, api, api_id):
        i = web.input(token=None)
        web.header('Content-Type', 'application/json')
        web.header('Access-Control-Allow-Origin', '*')
        
        ## Enforce https
        # TODO: sever SSL_ENABLED flag
        #if not web.ctx.protocol == "https":
        #    raise web.seeother("/404")

        ## Only allow verified users
        # TODO: Standardize errors
        if not i.token and i.token != server['secret']:
            return json.dumps({"error": "Unauthorized access, attempt logged"})
        return json.dumps({"error": "No data source available"})
Example #3
0
 def GET(self, src=None, dest=None):
     web.header('Content-Type', 'application/json')
     if not(src and dest):
         return json.dumps({"status": "error",
                            "msg": "required args: src & dest",
                            "code": "400 Bad Request",
                            "exception": "ValueError"
                            })
     try:
         data = phone.directions(src, dest)
     except :
         return json.dumps({"status": "error",
                            "msg": "JSON encoding error",
                            "code": "424 Method Failure",
                            "exception": "TypeError"
                            })
     return json.dumps({"status": "success",
                        "data": data
                        })
Example #4
0
 def inner(*args, **kwargs):
     web.header('Content-Type', 'application/json')
     return json.dumps(f(*args, **kwargs))
Example #5
0
 def GET(self):
     web.header('Content-Type', 'text/xml')
     return phone.sms("Please enter your current location.")
Example #6
0
 def GET(self):
     web.header('Content-Type', 'application/xml')
     return rss.feed(items_func())
Example #7
0
 def GET(self):
     web.header('Content-Type', 'application/json')
     return db().get('analytics')