Simple Way to Restart Python Flask on File Change During Development

When creating an API in Flask having to restart the process every time you make changes to your file is painful. Thankfully, it’s easy to set it up to restart whenever you save changes to your file.

Script

To do so you need to use these commands:

export FLASK_DEBUG=1
export FLASK_APP=name-of-your-python-file-here.py
flask run

Result

When the process starts you should see something like this:

When you save changes to your file you should then see something like this:

It’s simple, but it can save a lot of time and pain.

Here are some other posts on Python and Flask.

 

 

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *