def get(self):
     print 
     
     payload = json.loads(self.get_argument('payload'))
     print 'payload', payload
     results = handle_query(payload)
     conn = r.connect( "localhost", 28015).repl()
     r.db('public').table('queries').insert({'ip_address': self.request.headers.get("X-Forwarded-For"), 'datetime': r.expr(datetime.now(r.make_timezone('-07:00'))), 'payload': payload}).run(conn, noreply=True)
     print results
     self.set_header("Access-Control-Allow-Origin", "*")
     self.set_header("Access-Control-Allow-Headers", "accept, cache-control, origin, x-requested-with, x-file-name, content-type")  
     
     self.set_header("Content-Type", 'application/json')
     self.write(json.dumps(results))
    def get(self):
        print

        payload = json.loads(self.get_argument('payload'))
        print 'payload', payload
        results = handle_query(payload)
        conn = r.connect("localhost", 28015).repl()
        r.db('public').table('queries').insert({
            'ip_address':
            self.request.headers.get("X-Forwarded-For"),
            'datetime':
            r.expr(datetime.now(r.make_timezone('-07:00'))),
            'payload':
            payload
        }).run(conn, noreply=True)
        print results
        self.set_header("Access-Control-Allow-Origin", "*")
        self.set_header(
            "Access-Control-Allow-Headers",
            "accept, cache-control, origin, x-requested-with, x-file-name, content-type"
        )

        self.set_header("Content-Type", 'application/json')
        self.write(json.dumps(results))
def main():
    q = handle_query({'table': 'test_table'}, run=False).changes()
    ioloop.IOLoop.current().add_callback(print_changes, q)
def main():
    q = handle_query({'table': 'test_table'}, run=False).changes()
    ioloop.IOLoop.current().add_callback(print_changes, q)