Created
September 17, 2014 06:04
-
-
Save cjgiridhar/b8fde85a77249d0e538f to your computer and use it in GitHub Desktop.
Tornado Gen Coroutine
This file contains 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
import tornado.web | |
import tornado.gen | |
from tornado.httpclient import AsyncHTTPClient | |
class GenAsyncHandler(tornado.web.RequestHandler): | |
@tornado.gen.coroutine | |
def get(self): | |
http_client = AsyncHTTPClient() | |
response = yield http_client.fetch("http://ip.jsontest.com") | |
print(response) | |
application = tornado.web.Application([ | |
(r"/", GenAsyncHandler), | |
]) | |
if __name__ == "__main__": | |
application.listen(8888) | |
tornado.ioloop.IOLoop.instance().start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment