There are many Python web frameworks, such as Django,flask and so on. Today's main introduction to Tornado, Tornado is a relatively simple, non-barrier Web server architecture written in Python to handle tens of thousands of simultaneous connections, so that the real-time Web services open up. While similar to some of the current web architectures written in Python, such as Django, Tornado is more speed-conscious and able to handle massive amounts of simultaneous traffic. Next, let's start to roll up.
1. First you need to install the Tornado Library: Pip Install tornado
2. Create a new Python file (demo.py) code as follows:
Import Tornado.web
# define a class here and inherit the RequestHandler class as a routing class
Class MainHandler (Tornado.web.RequestHandler):
# Override the Get method
def get (self):
# Output content to interface
Self.write (' Hello, World ')
# Here is the routing configuration
App = Tornado.web.Application ([
('/', MainHandler),
] )
if __name__ = = ' __main__ ':
# Set the Listening port
App.listen (9999)
# Start the server
Tornado.ioloop.IOLoop.instance (). Start ()
3. Run demo.py without error, the description is successful, in the browser to access http://127.0.0.1:9999/can see
It's hello,world.
4. Summary:
About Tornado HelloWorld introduced here, later will update tornado more content, like my article, remember to pay attention to me oh, learn together, grow together!
Blog Park: Code life
Simple use of the tornado of the Python web framework