Download features/image_classifier/routes.py from Pujan-Dev/AI_API: direct link, hf CLI and curl.
- Browser
- Download file 761 Bytes
-
https://huggingface.co/spaces/Pujan-Dev/AI_API/resolve/main/features/image_classifier/routes.py
- Command line
-
hf download hf://spaces/Pujan-Dev/AI_API/features/image_classifier/routes.py
-
curl -L -o routes.py https://huggingface.co/spaces/Pujan-Dev/AI_API/resolve/main/features/image_classifier/routes.py
761 Bytes
| 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() | |
| async def analyse( | |
| request: Request, | |
| file: UploadFile = File(...), | |
| token: str = Depends(security) | |
| ): | |
| result = await Classify_Image_router(file) # await the async function | |
| return result | |
| def health(request: Request): | |
| return {"status": "ok"} | |