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_ENVenvironment variableENVkey 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()
Metadata
Release files for flask-configurator 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| flask_configurator-0.1.2.tar.gz | 3.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| flask_configurator-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.9 kB
Release files / flask_configurator-0.1.2.tar.gz
| Download URL | flask_configurator-0.1.2.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
51a51aad342ed421c53410240204f3ea8375712f003cf98d392cc689dc576187
|
|
BLAKE2b-256 checksum How to use checksums |
9190f2be9816b62b575baa4b94c39b9651377c6bb37f250f6c4133de2ddf21f1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.0
|
Release files / flask_configurator-0.1.2-py3-none-any.whl
| Download URL | flask_configurator-0.1.2-py3-none-any.whl |
|---|---|
| Size | 4.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7b63df3706a6b6ad2b066eeedac2a8d40c6f17e6006faad8030dd785a3302b95
|
|
BLAKE2b-256 checksum How to use checksums |
0acd6d7b6580207b6b61e7527bb84dcfe4afe9278b1c490737fd788b1d780040
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.0
|