I am trying to find out how to work with global variables in Flask:
gl = {'name': 'Default'}
@app.route('/store/<name>')
def store_var(name=None):
gl['name'] = name
return "Storing " + gl['name']
@app.route("/retrieve")
def retrieve_var():
n = gl['name']
return "Retrieved: " + n
Storing the name and retrieving it from another client works fine. However, this doesn't feel right: a simple global dictionary where any session pretty much simultaneously can throw in complex objects, does that really work without any dire consequences?