Skip to content

@kyledj /gist:3856206
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Flask app stack
from flask import Flask
from flask import _app_ctx_stack as stack
myapp = Flask(__name__)
def do_something():
ctx = stack.top
if ctx is None:
print "ctx is None"
else:
print "ctx is not None"
# Not during a request
do_something()
# During a request
# See http://flask.pocoo.org/docs/testing/
with myapp.test_request_context('/nowhere'):
do_something()
=======
Output
=======
ctx is None
ctx is not None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.