Giter Club home page Giter Club logo

flask-feature's Introduction

Flask-Feature

This Flask extension provides the ability to create feature flags in your code.

This allows you to selectively enable or disable features (for instance, enabled in development, disabled in production), or for admins of the site.

Build Status

Configuring your app

from flask.ext.feature import FeatureManager
feature = FeatureManager(app)

Alternatively, you can configure it with the factory pattern:

feature = FeatureManager()
feature.init_app(app)

Flask-Feature relies on a dictionary in the application's configuration in order to determine whether or not a feature is enabled.

Example:

app.config['FEATURES'] = {
    'test_key': True
}

As of now, the possible values for a key are: True, False, and 'admin'. If your key is set to 'admin', a function must be defined on your user object named is_admin(), which returns True if the given user is an admin, and False otherwise. If the user is an admin, and the feature is set to 'admin', is_enabled() will return True. Otherwise, it will return False.

There are future plans to allow whitelisting users, percentage based rampups, but they are not implemented as of now.

Accessing feature information

You can access feature information via the feature object on your app, like so:

app.feature.is_enabled('test_key') # This returns True

Additionally, by default, the feature manager registers a context processor for use in templates:

{% if feature.is_enabled('test_key') %}
    ...
{% endif %}

flask-feature's People

Contributors

btoconnor avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.