Quick flask ---

Acquaintance falsk

django is a large and comprehensive framework, flask is a lightweight frame.

 

flask rapid development site

flask very little code may be used directly to complete a project (line 6, 7), as follows:

from the Flask Import Flask 
① create objects Flask 
App = Flask ( __name__ )               # name is a name of the module, which can be written or string, or the path to a file 

② routing + view function 
@ app.route ( ' / index ' )              # decorator, access path is in brackets: HTTP: //127.0.0.1: 5000 / index 
DEF index ():                      # view function 
        return  ' Hello, World ' 

IF  the __name__ == ' __main__ ' : 
        app.run ( )                 # app.run isInternal call wekzeug, app is an object, the object + () to perform the method object __call__

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/shengjunqiye/p/11922350.html