Is it possible to change code of flask without rerunning the flask server after deployment? Is it possible to change code of flask without rerunning the flask server after deployment? flask flask

Is it possible to change code of flask without rerunning the flask server after deployment?


setting flask environment will do the thing for you in the shell.

export FLASK_ENV=development


Assuming you are using flask development server,

Yes, its possible using use_reloader=True,

from flask import Flaskapp = Flask(__name__)@app.route('/')def hello_world():    # You business logic code    return some_dataif __name__ == '__main__':    app.run(debug=False, host='0.0.0.0', port=8000,            use_reloader=True, threaded=True)

However it is not good idea to use it in production, related Is the server bundled with Flask safe to use in production?


My assumption is that you want your deployment service to recognize that a change has occurred in a file, which prompts it to automatically restart to reflect the changes, rather than you manually restarting the service.

Assuming that you are deploying on a production uWSGI server, starting the service with touch-reload=/path/to/folder would allow uWSGI to reload when the specified file/folder is modified or touched. https://uwsgi-docs.readthedocs.io/en/latest/Options.html#touch-reload

--touch-reload=/path/to/file.txt