Skip to main content

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:

  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()

Project details


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.1.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

flask_configurator-0.1.1-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: flask_configurator-0.1.1.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.8.0-48-generic

File hashes

Hashes for flask_configurator-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6b42c9f1dddef14c55162a1b3ecd8cb8d20aedb3dba5e3df26dfd03a00b233a3
MD5 952d380481a9ff48e28c7800a9997331
BLAKE2b-256 318abe6fb27e7fe03302df5a7ae91e51f4a5efec877943e25540844135d0861c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for flask_configurator-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f8efc187a4fea6b4a7cde2eab2f667b793082af2ff2318a52703c65ca493328f
MD5 3c44a1b6e57b20606266370145ebe26b
BLAKE2b-256 36c4a7ad14aa0a6412a72c277547d742ff1b12f389bc8f9e529dbf603d7f9067

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page