python - How to reload a configuration file on each request for Flask? -
is there idiomatic way have flask reload configuration file on every request? purpose of change passwords or other configuration related items without having shut down , restart server in production. edit: app.run(debug=true) not acceptable restarts server , shouldn't used in production. perhaps decorator following: def reload_configuration(func): @wraps(func) def _reload_configuration(*args, **kwargs): #even better, reload if file has changed reload(settings) app.config.from_object(settings.config) return func(*args, **kwargs) return _reload_configuration @app.route('/') @reload_configuration def home(): return render_template('home.html') if relevant, here how loading configuration now: my app/app/__init__.py file: from flask import flask settings import config app = flask(__name__) app.config.from_object(config) # ... my app/app/settings.py file: class config(object): sqlalchemy_track_...