Spaces:
Sleeping
Sleeping
Download app/security.py from FadQ/ACCESS-EMBEDDING: direct link, hf CLI and curl.
- Browser
- Download file 409 Bytes
-
https://huggingface.co/spaces/FadQ/ACCESS-EMBEDDING/resolve/main/app/security.py
- Command line
-
hf download hf://spaces/FadQ/ACCESS-EMBEDDING/app/security.py
-
curl -L -o security.py https://huggingface.co/spaces/FadQ/ACCESS-EMBEDDING/resolve/main/app/security.py
409 Bytes
| from fastapi import Header, HTTPException, status | |
| from app.config import get_settings | |
| def require_api_key(x_api_key: str | None = Header(default=None)) -> None: | |
| settings = get_settings() | |
| if not settings.api_key: | |
| return | |
| if x_api_key != settings.api_key: | |
| raise HTTPException( | |
| status_code=status.HTTP_401_UNAUTHORIZED, | |
| detail="Invalid API key", | |
| ) | |