Spaces:
Running
Running
File size: 761 Bytes
09c8783 b4f755d 09c8783 b4f755d 09c8783 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
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"}
|