Skip to content

configcat-labs/openfeature-python-sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenFeature Python Sample - Courses App

Read the blog post here

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.

Build & Run

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.

Prerequisites

  • 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
  1. Clone this repository:
git clone git@github.com:configcat-labs/openfeature-python-sample.git
  1. Navigate to the directory:

cd openfeature-python-sample

  1. Create a virtual environment with venv:
python -m venv .venv
  1. Activate the virtual environment:
# PowerShell
.venv\Scripts\Activate.ps1

# Linux, macOS
source .venv/bin/activate
  1. Install the dependencies: pip install -r requirements.txt

  2. Create a .env file in the project's root folder to store your ConfigCat SDK key:

CONFIGCAT_SDK_KEY="YOUR-SDK-KEY
  1. Run the app.
# For ConfigCat only

fastapi dev main.py

OR

# For ConfigCat + OpenFeature

fastapi dev cc-openfeature.py
  1. Click the link printed in your terminal to open the app in your browser, then go to the /courses route.

Learn more

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.

Author

Zayyad

Contributions

Contributions are welcome!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages