Coverage for opt/mealie/lib/python3.12/site-packages/mealie/routes/media/media_user.py: 85%
11 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 03:04 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 03:04 +0000
1from fastapi import APIRouter, HTTPException, status
2from pydantic import UUID4
3from starlette.responses import FileResponse
5from mealie.schema.user import PrivateUser
7router = APIRouter(prefix="/users")
10@router.get("/{user_id}/{file_name}", response_class=FileResponse)
11async def get_user_image(user_id: UUID4, file_name: str):
12 """Takes in a recipe slug, returns the static image. This route is proxied in the docker image
13 and should not hit the API in production"""
14 recipe_image = PrivateUser.get_directory(user_id) / file_name
16 if recipe_image.exists(): 16 ↛ 17line 16 didn't jump to line 17 because the condition on line 16 was never true
17 return FileResponse(recipe_image, media_type="image/webp")
18 else:
19 raise HTTPException(status.HTTP_404_NOT_FOUND)