Last active
October 28, 2021 21:01
-
-
Save chrisjws-harness/c462a6d1f9ee78181b216e8b11a7fd0c to your computer and use it in GitHub Desktop.
Python FF tutorial
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
harness-featureflags==1.0.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pip3 install -r requirements.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from featureflags.client import CfClient, Target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
meta = { | |
"account": "<your account id here>", | |
"org": "default", | |
"environment": "PyCharm", | |
"project": "Python_FF" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
flags["welcome_text"] = cf.string_variation("message", target, "test") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
python manage.py runserver |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment