from slowapi import Limiter from config import ACCESS_RATE from fastapi import APIRouter, File, Request, Depends, HTTPException, UploadFile from fastapi.security import HTTPBearer from slowapi import Limiter from slowapi.util import get_remote_address from .controller import Classify_Image_router router = APIRouter() limiter = Limiter(key_func=get_remote_address) security = HTTPBearer() @router.post("/analyse") @limiter.limit(ACCESS_RATE) async def analyse( request: Request, file: UploadFile = File(...), token: str = Depends(security) ): result = await Classify_Image_router(file) # await the async function return result @router.get("/health") @limiter.limit(ACCESS_RATE) def health(request: Request): return {"status": "ok"}