Python '_AppCtxGlobals': Attribute Error in Flask Python '_AppCtxGlobals': Attribute Error in Flask flask flask

Python '_AppCtxGlobals': Attribute Error in Flask


I had a similar issue and is due because you called a variable g, so flask confuse it with the global application context also called g.

Have a look here:https://flask.palletsprojects.com/en/1.1.x/api/#flask.ctx._AppCtxGlobals

Creating an app context automatically creates this object, which is made available as the g proxy.

So try renaming your g variable in g.request_start_time = time.time()that you probably inherit from somewhere else.

If you are referring the flask context and having error correlated to 404 requests, it might be that when you call after_request() it does not find any attribute g.request_start_time , maybe because if requests fail the attribute is not created.