Skip to main content

Flask feature flag

Project description

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}')

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_feature_flag-0.2.1.tar.gz (5.0 kB view hashes)

Uploaded source

Built Distribution

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page