print sys.exc_info() print_tb(sys.exc_info()[2]) return {"status": "failed", "reason": "could not retrieve your location"} def cache_taxis(): for taxi in json.loads(yapi.find_business("taxi", "montreal", time(), page_len=100))["listings"]: if taxi["geoCode"]: lat, lng = taxi["geoCode"]["latitude"], taxi["geoCode"]["longitude"] try: sql = "INSERT INTO taxis (lat, lng, yid, name) VALUES (%s, %s, %s, '%s');" % ( lat, lng, taxi["id"], re.sub("[^\da-zA-Z]", "-", unidecode(taxi["name"])), ) db.cursor.execute(sql) db.conn.commit() except: pass print "added taxi at %s,%s" % (lat, lng) app.debug = True if __name__ == "__main__": try: app.run(host="50.57.65.176") except: app.run()
class blah(): key = 'somekey' secret = 'somesecret' out = blah() return out oauth_protect.default_consumer = some_other_consumer @Endpoint('/main') class Main: '''Basic example returns a json response''' def get(*args,**kwargs): print args,kwargs return {'response': ['hello','world']} def post(*args,**kwargs): return {'response': ['you','posted']} def put(*args,**kwargs): return {'response': ['you','put', {'some': 'buttz', 'on': 'toast'}, 'gross']} def delete(*args,**kwargs): return {'response': {'status': 'success'}} app.debug = False app.run()