Flask feature flag
Project description
Flask feature flag
Tool to activate and deactivate project functionalities
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 typeFLASK_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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for flask_feature_flag-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f921c51e30d64e0cdd07ae8d57959a9f7bc8e93fadc343ddb4164d7d719461b0 |
|
MD5 | bff93bb3ed2af4c929902c106a65e18f |
|
BLAKE2-256 | bb1e052d3ce9847bb7506110023313c0e7566bababe8202505af6eebee1d4644 |