RuntimeError: Working outside of application context.
This typically means that you attempted to use functionality that needed
the current application. To solve this, set up an application context
with app.app_context(). See the documentation for more information.
官方文档:
If you try to accesscurrent_app
, or anything that uses it, outside an application context, you’ll get this error message:
If you see that error while configuring your application, such as when initializing an extension, you can push a context manually since you have direct access to the app
. Use app_context()
in a with
block, and everything that runs in the block will have access to current_app
.
If you see that error somewhere else in your code not related to configuring the application, it most likely indicates that you should move that code into a view function or CLI command.
https://blog.csdn.net/weixin_44936542/article/details/112175582
作者:_gitignore
链接:https://www.jianshu.com/p/05e468fbdda3
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。 标签:access,flask,app,current,application,context,error From: https://www.cnblogs.com/yijianye/p/16862234.html