Skip to main content

Flask feature flag

Tool to activate and deactivate project functionalities

pipeline status coverage report

Package installation

  • Installation
    $ pip3 install flask-feature-flag
    

Configuration

  • Feature flag type availables.

    • FLASK_CONFIG
    • MONGO
  • Define the following to your config.py

    FEATURE_FLAG_TYPE=
    

    FEATURE_FLAG_TYPE is required.

  • You should add this to your config.py if it's feature type FLASK_CONFIG

    FEATURE_FLAGS = {
        'ROUTE_ENABLED': os.environ.get('ROUTE_ENABLED', True)
    }
    

    FEATURE_FLAGS is required.

Docs

Example:

is_enabled this decorator allows to activate or deactivate a functionality and receives as parameters a function to return in case feature is disabled and the name of the feature

from flask import Flask
from flask_caching import Cache
from flask_feature_flag import Flag

config = {
    "DEBUG": True,
    "CACHE_TYPE": "simple",
    "FEATURE_FLAG_TYPE": "MONGO"
}
app = Flask(__name__)
# tell Flask to use the above defined config
app.config.from_mapping(config)
cache = Cache(app)
flag = Flag(app, cache)

def error():
    return dict(massage='this is a mistake')

@flag.is_enabled(error, 'ENV_HELLO')
def hello(name):
    return dict(message=f'Hi, {name}')

Metadata

Release files for flask-feature-flag 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flask-feature-flag 0.2.1
File Size Uploaded
flask_feature_flag-0.2.1.tar.gz 5.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for flask-feature-flag 0.2.1
File Interpreter ABI Platform
flask_feature_flag-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 12.2 kB

Release files / flask_feature_flag-0.2.1.tar.gz

Download URL flask_feature_flag-0.2.1.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b3c2090ae527d142cbf3cbaefa4ce7b9285b856e333eea3fd8610132788862cd
BLAKE2b-256 checksum
How to use checksums
7b2c59a27cbb9117624584cfc1babe1cdd6cd52d849013e74c172ce810a989a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.7

Release files / flask_feature_flag-0.2.1-py3-none-any.whl

Download URL flask_feature_flag-0.2.1-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f921c51e30d64e0cdd07ae8d57959a9f7bc8e93fadc343ddb4164d7d719461b0
BLAKE2b-256 checksum
How to use checksums
bb1e052d3ce9847bb7506110023313c0e7566bababe8202505af6eebee1d4644
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.7
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page