从Flask源代码中
flask/globals.py:
_app_ctx_err_msg = '''Working outside of application context.This typically means that you attempted to use functionality that neededto interface with the current application object in a way. To solvethis set up an application context with app.app_context(). See thedocumentation for more information.'''
通过该文档,您可以看到您需要
flask.current_app指向您的应用程序,而当前并不需要。
您可能在Flask初始化之前调用了DB函数。我的猜测是您的
app对象尚未使用
Flask构造函数创建。



