This repository accompanies the article "Announcing Official Support for OpenFeature." The sample app is a simple Python FastAPI application that returns a list of courses from its /courses
route. It was built to demonstrate integrating OpenFeature into an existing app that uses ConfigCat feature flags.
This repository has two Python files:
main.py
: uses only ConfigCat for feature flag evaluation.cc-openfeature.py
: uses OpenFeature + ConfigCat for feature flag evaluation.
Follow the steps in the upcoming sections to run any of the two files.
- A ConfigCat account
- Python v3.9+
- Git v2.33+
- A tool to make HTTP requests (curl, Postman, Thunder client, etc.)
- Intermediate knowledge of Python and FastAPI and basic knowledge of Git
- Clone this repository:
git clone git@github.com:configcat-labs/openfeature-python-sample.git
- Navigate to the directory:
cd openfeature-python-sample
- Create a virtual environment with
venv
:
python -m venv .venv
- Activate the virtual environment:
# PowerShell
.venv\Scripts\Activate.ps1
# Linux, macOS
source .venv/bin/activate
-
Install the dependencies:
pip install -r requirements.txt
-
Create a
.env
file in the project's root folder to store your ConfigCat SDK key:
CONFIGCAT_SDK_KEY="YOUR-SDK-KEY
- Run the app.
# For ConfigCat only
fastapi dev main.py
OR
# For ConfigCat + OpenFeature
fastapi dev cc-openfeature.py
- Click the link printed in your terminal to open the app in your browser, then go to the
/courses
route.
- ConfigCat OpenFeature Provider for Python - Read the providers' documentation.
- OpenFeature Python SDK - Learn more about OpenFeature's Python SDK.
- ConfigCat OpenFeature Providers - Check out the available OpenFeature providers.
- OpenFeature - Learn more about OpenFeature.
ConfigCat supports many other frameworks and languages. Check out the full list of supported SDKs here.
You can also explore other code samples for various languages, frameworks, and topics in ConfigCat labs on GitHub.
Keep up with ConfigCat on X, Facebook, LinkedIn, and GitHub.
Contributions are welcome!