在类属性读 flask 的配置报错
from flask import current_app
class Foo(object):
URL = current_app.config['EX_URL']
...
File "/path/to/example.py", line 20, in Foo
URL = current_app.config['EX_URL']
File "/path/to/miniconda/envs/example/lib/python3.8/site-packages/werkzeug/local.py", line 347, in __getattr__
return getattr(self._get_current_object(), name)
File "/path/to/miniconda/envs/example/lib/python3.8/site-packages/werkzeug/local.py", line 306, in _get_current_object
return self.__local()
File "/path/to/miniconda/envs/example/lib/python3.8/site-packages/flask/globals.py", line 52, in _find_app
raise RuntimeError(_app_ctx_err_msg)
RuntimeError: Working outside of application context.
This typically means that you attempted to use functionality that needed
to interface with the current application object in some way. To solve
this, set up an application context with app.app_context(). See the
documentation for more information.
提示是让执行 app.app_context() , 我尝试导入 from start import app 后执行, 又报了循环导入的问题, 想请教这个该怎么解决