Download app/dependencies.py from mgbam/AICEO: direct link, hf CLI and curl.
- Browser
- Download file 584 Bytes
-
https://huggingface.co/spaces/mgbam/AICEO/resolve/74575acfb18e167e2669eae0b9ebcdcd289112d8/app/dependencies.py
- Command line
-
hf download hf://spaces/mgbam/AICEO@74575acfb18e167e2669eae0b9ebcdcd289112d8/app/dependencies.py
-
curl -L -o dependencies.py https://huggingface.co/spaces/mgbam/AICEO/resolve/74575acfb18e167e2669eae0b9ebcdcd289112d8/app/dependencies.py
584 Bytes
| # app/dependencies.py | |
| import os | |
| from fastapi import Header, HTTPException, Depends | |
| def require_api_key(x_api_key: str = Header(...)): | |
| """ | |
| Simple header-based API key check. | |
| The key is read from the environment variable API_KEY, which you set in | |
| Settings → Secrets on your Hugging Face Space. | |
| """ | |
| expected_key = os.getenv("API_KEY") | |
| if not expected_key: | |
| raise HTTPException(status_code=500, detail="API_KEY not configured") | |
| if x_api_key != expected_key: | |
| raise HTTPException(status_code=403, detail="Invalid API Key") | |
| return True | |