I am looking for a ways to share global data across all views of the flask application
__init__.py
from flask import Flask
app = Flask(__name__)
app.gcp = googleCloudSessionObjectA()
aview.py
from flask import current_app as app
@app.route('/abc')
def foo():
print(app.gcp) # here it prints the string representation of A
app.gcp = googleCloudSessionObjectB() # this one does not change the global app object
return render_template('base.html')
I want to be able to change the value of app.gcp
in a view after importing the current_app
object. And I want this value to be available throughout the application.
What am I doing wrong?