flask-feature-flag-0.2.1
توضیحات
Flask feature flag
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | flask-feature-flag-0.2.1 |
| نام | flask-feature-flag |
| نسخه کتابخانه | 0.2.1 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Terminus |
| ایمیل نویسنده | jose.salas@zinobe.com |
| آدرس صفحه اصلی | https://gitlab.com/terminus-zinobe/flask-feature-flag |
| آدرس اینترنتی | https://pypi.org/project/flask-feature-flag/ |
| مجوز | - |
# Flask feature flag
Tool to activate and deactivate project functionalities
[](https://gitlab.com/terminus-zinobe/flask-feature-flag/-/commits/master) [](https://gitlab.com/terminus-zinobe/flask-feature-flag/-/commits/master)
## Package installation
- Installation
```shell
$ pip3 install flask-feature-flag
```
## Configuration
- Feature flag type availables.
* FLASK_CONFIG
* MONGO
- Define the following to your `config.py`
```python
FEATURE_FLAG_TYPE=
```
`FEATURE_FLAG_TYPE` is required.
- You should add this to your `config.py` if it's feature type `FLASK_CONFIG`
```python
FEATURE_FLAGS = {
'ROUTE_ENABLED': os.environ.get('ROUTE_ENABLED', True)
}
```
`FEATURE_FLAGS` is required.
## Docs
- [Flask-Feature-Flag’s documentation](https://flask-feature-flag-docs.readthedocs.io/en/latest/index.html)
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
```python
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}')
```
نیازمندی
| مقدار | نام |
|---|---|
| >=1.1.1 | flask |
| >=0.9.5 | flask-mongoengine |
| >=1.8.0 | Flask-Caching |
| >=0.0.1 | constants-and-utils |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.6 | Python |
نحوه نصب
نصب پکیج whl flask-feature-flag-0.2.1:
pip install flask-feature-flag-0.2.1.whl
نصب پکیج tar.gz flask-feature-flag-0.2.1:
pip install flask-feature-flag-0.2.1.tar.gz