Skip to content

Instantly share code, notes, and snippets.

@chrisjws-harness
Last active October 28, 2021 21:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrisjws-harness/c462a6d1f9ee78181b216e8b11a7fd0c to your computer and use it in GitHub Desktop.
Save chrisjws-harness/c462a6d1f9ee78181b216e8b11a7fd0c to your computer and use it in GitHub Desktop.
Python FF tutorial
# Clone the repo, move the files around and clean up the folder
git clone https://github.com/chrisjws-harness/flaskSaaS.git && mv flaskSaaS/*(DN) . && rm -rf flaskSaaS
# Setup and run the application
make install && make dev
python manage.py initdb
harness-featureflags==1.0.5
pip3 install -r requirements.txt
from featureflags.client import CfClient, Target
meta = {
"account": "<your account id here>",
"org": "default",
"environment": "PyCharm",
"project": "Python_FF"
}
try:
api_key = "<your key>"
cf = CfClient(api_key)
ff_identifier = "guest"
ff_name = "guest"
target = Target(identifier=ff_identifier, name=ff_name, **meta)
except Exception as e:
print(e)
flags["welcome_text"] = cf.string_variation("message", target, "test")
python manage.py runserver
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment