Preface
Flask Django package is less than perfect features, performance is less than Tornado, but Flask third party open source components than rich.
If you are a lover of minimalist style perfectionist, then Flask for you.
app object initialization and configuration
flask application object initialization parameter description
App = the Flask ( __name__ , static_url_path = " / Python " , # url prefix to access static resources, the default value is static static_folder = " static " , # directory static files, the default is static template_folder = " Templates " , # template file directory, the default is Templates )
Using a configuration file
# Configuration parameters use # 1. profile # app.config.from_pyfile ( "the config.cfg") # 2. Configuration parameters using object class Config (Object): the DEBUG = True ITCAST = " Python " the app.config. from_object (config) # # 3. direct operating config dictionary objects # the app.config [ "the DEBUG"] = True
Read mode configuration parameters
# Reads the configuration parameters # 1. config values directly from the dictionary in the global object app # Print (app.config.get ( "ITCAST")) # 2. acquisition parameters of CURRENT_APP Print (current_app.config.get ( " ITCAST " ))
app is run instructions
IF __name__ == ' __main__ ' : # Start program flask # app.run () app.run (Host = " 0.0.0.0 " , Port = 5000, Debug = True)
Route view function
data