Test-friendly configuration

One of the first obstacles faced by writing tests in a team or with a production environment is, How do we make sure that the tests are run without interfering with the production or even the development database. You certainly don't want to be attempting to fix bugs, or trialing new features and then finding that the data it relies upon has changed. Sometimes, a quick test just needs to be run on a local copy of the database without interference from anyone else, with the Flask app knowing how to use that.

One of the features built into Flask is the ability to load a configuration file depending on the environment variables.

app.config.from_envvar('FLASK_APP_BLOG_CONFIG_FILE')

The preceding method call informs your Flask ...

Get Learning Flask Framework now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.