Simple use of the tornado of the Python web framework

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.