The reloading behavior is associated with the running of an app, so is a feature of the Flask development server (and more specifically, is enabled with through the debug
flag), as opposed to a Flask app in-and-of itself. If you are using another WSGI server for running your app, then it will likely have this feature also which you may need to enable explicitly. For instance, gunicorn has a --reload
flag.
Now would also be a good time to mention that when using the Flask development server, the Flask docs don’t recommend using the Flask.run()
method (which the Dash docs use) if you want reliable auto-code reloading. Instead they recommend running flask run
from the command line and specifying the location of the WSGI callable (eg app.server
for Dash) the command line.
In general, these methods only work for Python files that your app imports. However you don’t actually need the server to reload your CSS and JS files, as Flask just directs requests for these to the files on the file systems (assuming you’re using Flask to serve static assets), serving whatever the current version is. The one caveat here is that browsers can aggressively cache static assets. So to ensure you get the current version, you can bypass the cache by hitting CTRL+F5.