打算用Flask CLI替换掉项目中的Flask-Script,于是去读Flask CLI的文档。

基本使用

For the flask script to work, an application needs to be discovered. This is achieved by exporting the FLASK_APP environment variable. It can be either set to an import path or to a filename of a Python module that contains a Flask application.
In that imported file the name of the app needs to be called app or optionally be specified after a colon. For instance mymodule:application would tell it to use the application object in the mymodule.py file.

使用Flask CLI,首先需要通过声明环境变量FLASK_APP来导入一个Flask applicationFLASK_APP可以指向import path中的Flask application,也可以指向一个内含了Flask application的模块。