[Flask] Globally accessible variables in Flask
badrihippo at gmail.com
badrihippo at gmail.com
Tue Apr 11 08:39:59 EDT 2017
I know I figured this out sometime, but can't remember now. How does
one make a variable that is automatically accessible to all views?
I mean like the current_user variable provided by Flask-Admin: it
automatically calculates current_user and makes it available to the
view for each request, without having to manually define it each time.
Basically, make it so that instead of...
> @app.route('/example')
> def example():
> my_var = something()
>
> @app.route('/example/2')
> def second_example():
> my_var = something()
...it automatically calculates my_var without having to manually define
it in each view.
Okay, I hope that was clear. And thanks in advance!
—Badri/Hippo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20170411/9fe10a12/attachment.html>
More information about the Flask
mailing list