Spaces:
Runtime error
Runtime error
File size: 450 Bytes
1cfeb58 ce2ce69 22c7fb1 b7b6eaf 1cfeb58 71192d1 ce2ce69 71192d1 ce2ce69 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
import os
import logging
from fastapi import Header, HTTPException, status
API_KEY = os.getenv("WELLSAID_API_KEY", "12345")
def verify_api_key(x_api_key: str = Header(...)) -> None:
if not x_api_key or x_api_key != API_KEY:
logging.warning("Unauthorized access attempt with key: %s", x_api_key)
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail="Invalid or missing API key"
)
|