Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Tornado - Hello World
## Torando Web Server hello World
import tornado.ioloop
import tornado.web
class Hello(tornado.web.RequestHandler):
def get(self):
self.write("Hello, world")
application = tornado.web.Application([
(r"/", Hello),
])
if __name__ == "__main__":
application.listen(8888)
tornado.ioloop.IOLoop.instance().start()
## Request to Torando Web server Hello World
import httplib2
h = httplib2.Http()
resp, content = h.request("http://127.0.0.1:8888", "GET")
print "Reponse:", resp, "\nContent:", content
Reponse: {'status': '200', 'content-length': '12', 'content-location': 'http://127.0.0.1:8888', 'server': 'TornadoServer/2.2',
'etag': '"e02aa1b106d5c7c6a98def2b13005d5b84fd8dc8"', 'content-type': 'text/html; charset=UTF-8'}
Content: Hello, world
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment