Centos Tornado Server Installation Tutorial
Install using repository
yum install python-tornado
First ‘Hello World’ App
I’ve copied the hello world sample from Tornado documentation:
Create a new file called ‘hello.py‘ (or any other name) and fill it with:
1 2 3 4 5 6 7 8 9 10 11 12 13 | 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) tornado.ioloop.IOLoop.instance().start() |
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) tornado.ioloop.IOLoop.instance().start()
Now start your server with simply typing at bash:
1 | python hello.py |
python hello.py
Now you can visit ‘127.0.0.1:8888‘ to watch your hello world first torando app.
It should return the ‘Hello, world‘ output into your browser.
Nginx
Good implementation of your server would be behind nginx server, where you can run multiple instances of your app on different port and serve them all throw port 80 using nginx load balancer.
http://www.tornadoweb.org/en/latest/overview.html#running-tornado-in-production
After you know how to start a torando server, you can jump into the documentation and learn how-to build your first Torando server!
Development Specialist, Artist and Activist
Personal Website