Python Web Server with Tornado

Tornado is an Open Source Web Server for Python really interesting. It powers the FriendFeed and it is listed in the Facebook Open Source Technology page for Infrastructure.

I tried quickly on my Ubuntu 10.10 Laptop and it is really simple to install and test.

Just open a terminal and type:

  • sudo apt-get install python-pycurl
  • sudo apt-get install pip
  • sudo pip install tornado
  • vi hello.py and write an hello world web application like this
  • import tornado.ioloop
    import tornado.web
    
    class MainHandler(tornado.web.RequestHandler):
      def get(self):
      self.write("Hello, world")
    
      application = tornado.web.Application([
        (r"/", MainHandler),
      ])
    
    if __name__ == "__main__":
      application.listen(8888)
    
  • python hello.py
  • open the browser and go to http://localhost:8888

Thats it!

3 thoughts on “Python Web Server with Tornado

Leave a reply to giulioroggero Cancel reply