'Flask App - Local Development Environment - changes not reflecting
I have a Flask App that I am running locally and testing. Every time, I make a change in the Application code, the changes would reflect on the dev environment http://127.0.0.1:8000/ with a simple browser refresh.
Now, I have to terminate the Flask App Ctrl X + Ctrl C and then reboot / relaunch the App. I am using gunicorn to launch the Flask App.
Not sure what changed, but how do I configure the App such that the changes take effect on refresh?
I have the following line of code in init.py:
if __name__ == '__main__':
run_simple('0.0.0.0', 80, app, use_reloader=True, use_debugger=True)
Solution 1:[1]
Gunicorn has its own system to reload the worker process when the application code changes. You can use the --reload CLI flag to activate the auto-reloading dev mode.
gunicorn --reload app:app
You can add additional files to the watcher via the --reload-extra-file FILES arg.
Solution 2:[2]
Try
if __name__ == '__main__':
app.run(debug=True)
Also using Gunicorn
web: gunicorn wsgi:app
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dauros |
| Solution 2 | Otu William |
