Skip to main content

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:

  1. development if app.debug, production otherwise
  2. FLASK_ENV environment variable
  3. ENV 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()

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flask_configurator-0.1.2.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flask_configurator-0.1.2-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file flask_configurator-0.1.2.tar.gz.

File metadata

  • Download URL: flask_configurator-0.1.2.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.0

File hashes

Hashes for flask_configurator-0.1.2.tar.gz
Algorithm Hash digest
SHA256 51a51aad342ed421c53410240204f3ea8375712f003cf98d392cc689dc576187
MD5 9ffcb4e352068a1cca590dda15079589
BLAKE2b-256 9190f2be9816b62b575baa4b94c39b9651377c6bb37f250f6c4133de2ddf21f1

See more details on using hashes here.

File details

Details for the file flask_configurator-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for flask_configurator-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7b63df3706a6b6ad2b066eeedac2a8d40c6f17e6006faad8030dd785a3302b95
MD5 a1fd2506d7fd535e48b2e7aa8e262395
BLAKE2b-256 0acd6d7b6580207b6b61e7527bb84dcfe4afe9278b1c490737fd788b1d780040

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page