diff --git a/python-uv/README.md b/python-uv/README.md index a4f7d38d9a..e674ad5ff3 100644 --- a/python-uv/README.md +++ b/python-uv/README.md @@ -1,3 +1,10 @@ # Managing Python Projects With `uv`: An All-in-One Solution This folder provides the code examples for the Real Python tutorial [Managing Python Projects With `uv`: An All-in-One Solution](https://realpython.com/python-uv/). + +The sample app uses the [Cat API](https://thecatapi.com/), which requires an API key. Get one from the Cat API website and store it in an environment variable called `CAT_API_KEY` before running the app: + +```sh +$ export CAT_API_KEY= +$ uv run main.py Persian +``` diff --git a/python-uv/main.py b/python-uv/main.py index 542fe1750b..edfe93abd6 100644 --- a/python-uv/main.py +++ b/python-uv/main.py @@ -1,11 +1,15 @@ import argparse +import os import sys import requests def get_breeds_info(): - response = requests.get("https://api.thecatapi.com/v1/breeds") + response = requests.get( + "https://api.thecatapi.com/v1/breeds", + headers={"x-api-key": os.environ.get("CAT_API_KEY", "")}, + ) response.raise_for_status() return response.json()