Created
February 16, 2016 03:53
-
-
Save Wesitos/0f8f5928cdf386dd8234 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tornado.ioloop import IOLoop | |
import tornado.web | |
import tornado.httpserver | |
from motor.motor_tornado import MotorClient | |
from pprint import pprint | |
class AnimalHandler(tornado.web.RequestHandler): | |
async def get(self): | |
collect = db.animales | |
res_list = [] | |
async for d in collect.find({}, {"_id": False}): | |
pprint(d) | |
res_list.append(d) | |
self.write({"data": res_list}) | |
app = tornado.web.Application([ | |
("/", AnimalHandler), | |
]) | |
if __name__ == "__main__": | |
server = tornado.httpserver.HTTPServer(app) | |
server.bind(8888) | |
server.start(0) # Forks multiple sub-processes | |
db = MotorClient().test | |
IOLoop.current().start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment