Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

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.

Files for flask-feature-flag, version 0.2.1
Filename, size File type Python version Upload date Hashes
Filename, size flask_feature_flag-0.2.1-py3-none-any.whl (7.2 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size flask_feature_flag-0.2.1.tar.gz (5.0 kB) File type Source Python version None Upload date Hashes View

Supported by

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