Env and file based configuration for Flask
Project description
Flask-Configurator
Env and file based configuration for Flask
Installation
pip install flask-configurator
Usage
from flask import Flask
from flask_configurator import Configurator
app = Flask(__name__)
Configurator(app)
By default this will load configuration from:
- environment variables with the FLASK_ prefix
- .env (only variables with the FLASK_ prefix)
- .env.ENV (only variables with the FLASK_ prefix)
- config.yml
- config.ENV.yml
Where ENV is the environment defined as defined by:
- development if app.debug, production otherwise
FLASK_ENV
environment variableENV
key from any loaded file
Options
Configurator(
app,
default_file="config.yml", # default configuration file to load from (set to None to disable)
env_prefix="FLASK", # environment variable prefix
default_env="production", # default env name (None for default, False to not set any env)
)
Supported configuration formats: yml, json, toml.
Manual loading
Rather than going through an extension, you can use our custom Config class.
from flask_configurator import Config
config = Config()
config.load()
print(config["KEY"])
app.config.update(config)
Use it as your flask config class:
from flask import Flask
from flask_configurator import Config
class CustomFlask(Flask):
config_class = Config
app = CustomFlask(__name__)
app.config.load()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for flask_configurator-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6125b23e90340ca072591333d733d8e72cb0cd1cba00a2ea2db8fd7634a399b |
|
MD5 | 7e1423be64a9e2e7309407052bf4aafb |
|
BLAKE2b-256 | ada64fecfd40b55be2bde3e6bb4dd7bacf09a43a59b98afaf79639c716ed81c0 |