#33: Activate Auto-Reload for Flask in VS Code
The default launch configuration in VS Code for Flask is a great help. However, there is one little optimisation that massively improves your development experience.
Activate auto-reload
When you are writing your code, you make changes and want to see them in the browser. VS Code allows you to change your code while you run the debugger, but the default launch configuration requires you to stop and start the debugger before you can see your change. We can get rid of this extra step with 2 changes in the launch.json file:
On line 15 we activated FLASK_DEBUG by switching the value from 0 to 1. In the args dictionary we need to remove the option "--no-reload" (that is in the original launch.json file in line 20).
If we now make a change and save our file, Flask will detect the change and automatically restart the server:
All we need to do is to hit reload in our browser.
Conclusion
With this little change we can develop without constantly restarting the web server. This will help us a lot when we add more features to our application.