File size: 464 Bytes
7a1dae9
 
 
 
 
 
 
 
 
 
 
 
 
82a94f5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
from fastapi import HTTPException
import os

def validate_token(token: str):
    """
    Validate the provided token against the HF_TOKEN environment variable.
    Raises an HTTPException if validation fails.
    """
    HF_TOKEN = os.getenv("VEUREU_TOKEN")
    if HF_TOKEN is None:
        raise RuntimeError("HF_TOKEN environment variable is not set on the server.")

    if token != HF_TOKEN:
        raise HTTPException(status_code=401, detail="Invalid token")