[Understanding] Flask Flask

Python Web framework at this stage the three main contrast Django Tornado Flask

Baidu Encyclopedia

1.Django main feature is the large and integrates a number of components, such as: Models Admin Form, etc., whatever you get less than, anyway, it is all there, it belongs to the versatile framework

2.Tornado main feature is asynchronous non-blocking native, occupy absolute advantage in the IO-intensive applications and multitasking, are preoccupied framework

3.Flask main features of small and light, the native component is almost zero, the three parties to provide components, please refer to Django very comprehensive, is dapper-frame

Django is usually used for large Web applications due to the built-in component is strong enough so you can use the Django development in one go

Tornado API typically used for back-end applications, games service background, its internal implementation of a number of asynchronous non-blocking was really steady

Flask is usually used in small applications and quickly build applications, its powerful tripartite library, enough to support a large-scale Web applications

Django advantage is large and shortcomings will be exposed, and so many resources all at once loaded, will certainly be a part of the waste of resources

Tornado advantage is asynchronous, the disadvantage is clean, not even a Session Support

Flask advantage is lean and simple, the disadvantage is that you will not!

Flask installation

pip install flask

The first program of the flask

Copy the code
# - * - Coding: UTF-. 8 - * - 
# @time: 2019/7/10 9:36 
from Flask Flask # Import introduced class Flask 

app = Flask (__ name__) # Flask instantiated objects App 

app.debug = True # automatic restart service
# app.config["DEBUG"] = True
route decorator @ app.route ( "/ index") # app in 
def index (): # view function 
    return "hello word" # response value 

IF the __name__ == '__main__': 
    app.run ( "0.0.0.0" , 9876) # ip port designated start Flask web service
Copy the code

Get page

Guess you like

Origin www.cnblogs.com/youxiu123/p/11605763.html