Spaces:
Sleeping
Sleeping
Download libs/header_api_auth.py from minhpng/test_python: direct link, hf CLI and curl.
- Browser
- Download file 604 Bytes
-
https://huggingface.co/spaces/minhpng/test_python/resolve/36d3ea0a02fc0bfc6d99b2ff7d2db9442db5817d/libs/header_api_auth.py
- Command line
-
hf download hf://spaces/minhpng/test_python@36d3ea0a02fc0bfc6d99b2ff7d2db9442db5817d/libs/header_api_auth.py
-
curl -L -o header_api_auth.py https://huggingface.co/spaces/minhpng/test_python/resolve/36d3ea0a02fc0bfc6d99b2ff7d2db9442db5817d/libs/header_api_auth.py
604 Bytes
| from fastapi import Depends, HTTPException, status | |
| from fastapi.security import APIKeyHeader | |
| API_KEYS = ['Fo0nxlisbbKOlZfnir6_5Tv4hHyNF8sv94f7lxA9iK3ApUuT3wmGuQ', 'wsAlgiZ_Bvncop-BGlua2FqsrKj7Ex8mgDN2F-UsfJ2yQpnwHODg9Q', 'wIjqpBXazXUZmqJ8vTKF0yUXjNihX9JSEfk3-3aFQbM-DBtu2ccnVQ'] | |
| api_key_header = APIKeyHeader(name="x-api-key", auto_error=False) | |
| def get_api_key(api_key_header: str = Depends(api_key_header)): | |
| if api_key_header in API_KEYS: | |
| return api_key_header | |
| raise HTTPException( | |
| status_code=status.HTTP_401_UNAUTHORIZED, | |
| detail="Invalid or missing API Key", | |
| ) | |