Skip to content

Instantly share code, notes, and snippets.

@ntrepid8
Created February 1, 2014 15:33
Show Gist options
  • Save ntrepid8/8753799 to your computer and use it in GitHub Desktop.
Save ntrepid8/8753799 to your computer and use it in GitHub Desktop.
class MessagesHandler(tornado.web.RequestHandler):
@tornado.web.asynchronous
@tornado.gen.engine
def get(self):
db = self.settings['db']
rb = []
cursor = db.messages.find().sort([('_id', -1)])
while (yield cursor.fetch_next)
message = cursor.next_object()
rb.append({
'id': message['_id'],
'msg': message['msg']
})
self.finish({"data": rb})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment