4.1 flask中经典错误 working outside application context
from flask import Flask, current_app
app = Flask(__name__)
# 断点调试这里显示current_app=[LocalProxy]<LocalProxy unbound>
a = current_app
# RuntimeError: Working outside of application context.
b = current_app.config["DEBUG"]# context locals
_request_ctx_stack = LocalStack()
_app_ctx_stack = LocalStack()
current_app = LocalProxy(_find_app)
request = LocalProxy(partial(_lookup_req_object, 'request'))
session = LocalProxy(partial(_lookup_req_object, 'session'))
g = LocalProxy(partial(_lookup_app_object, 'g'))Last updated
Was this helpful?