Spaces:
Sleeping
Sleeping
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", | |
) | |