def has_request_context():
 return (_request_ctx_stack.top is not None)

def has_request_context ( ) : return ( _request_ctx_stack . top is not None )
if you have code that wants to test if a request context is there or not this function can be used .