Spaces:
Sleeping
Sleeping
File size: 464 Bytes
82276a6 283373b 74a9b66 82276a6 5b90a2e 82276a6 74a9b66 5b90a2e 82276a6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
from fastapi.security.api_key import APIKeyHeader
from fastapi import Security, HTTPException
import os
# from dotenv import load_dotenv
api_key_header = APIKeyHeader(name="x-api-key", auto_error=False)
async def api_key_auth(api_key: str = Security(api_key_header)):
# for local
# load_dotenv()
API_Keys = [os.environ.get('API_KEY')]
if api_key not in API_Keys:
raise HTTPException(status_code=401, detail="Missing or invalid API key") |