Sentry Answers>Flask>

Auto-reloading a Flask application

Auto-reloading a Flask application

James W.

The Problem

You are working on a Flask project and notice that the process of manually reloading your Flask application every time you save new changes is tedious and inefficient.

Is there a way to automatically reload your Flask application whenever you save changes to your code?

The Solution

Use the --debug option when you run your Flask app to enable debug mode.

Click to Copy
flask --app example_app.py --debug run

This will enable auto-reload whenever changes are made to your code and saved. It will also enable an interactive debugger in the browser if any errors occur during a request.

For more information about running your Flask app, run the following command to get a list of options:

Click to Copy
flask run --help
  • SentryFlask Error Monitoring (opens in a new tab)
  • Syntax.fmListen to the Syntax Podcast (opens in a new tab)
  • Community SeriesIdentify, Trace, and Fix Endpoint Regression Issues (opens in a new tab)
  • Syntax.fm logo
    Listen to the Syntax Podcast (opens in a new tab)

    Tasty treats for web developers brought to you by Sentry. Get tips and tricks from Wes Bos and Scott Tolinski.

    SEE EPISODES

Considered “not bad” by 4 million developers and more than 150,000 organizations worldwide, Sentry provides code-level observability to many of the world’s best-known companies like Disney, Peloton, Cloudflare, Eventbrite, Slack, Supercell, and Rockstar Games. Each month we process billions of exceptions from the most popular products on the internet.