Skip to content

Instantly share code, notes, and snippets.

@cjgiridhar
Created July 25, 2012 06:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cjgiridhar/3174653 to your computer and use it in GitHub Desktop.
Save cjgiridhar/3174653 to your computer and use it in GitHub Desktop.
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