Source of Flask: Configuring load

Load idea of ​​the configuration file:

1. Read all the key profile and all key-value pairs into the Config object. (Config is a dictionary, because it inherits Dict)

2. Config object contains all the configuration files, assigned to app.config, then you can use to call app.config configuration.

app.config.from_object ( 'xx.xx' ) is used to load the configuration file configuration xx.xx

Project start:
 from the Flask Import the Flask

app = Flask(__name__,static_url_path='/xx')

# app.config =  Config对象
# Config对象.from_object('xx.xx')
# app.config
app.config.from_object('xx.xx')

@app.route('/index')
def index():
        return 'hello world'

if __name__ == '__main__':
        app.run()

 

Guess you like

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