Améliorations gestion des images
This commit is contained in:
parent
ef3e875953
commit
3fdb2b7641
13 changed files with 542 additions and 10 deletions
|
@ -10,7 +10,7 @@ from models import User
|
|||
router = APIRouter()
|
||||
|
||||
@router.get("/")
|
||||
async def get_images(current_user: Annotated[User, Depends(get_current_active_user)]):
|
||||
async def get_images():
|
||||
# list all files in resources/images
|
||||
files = [f for f in os.listdir(f"{os.getcwd()}/resources/images") if os.path.isfile(os.path.join(f"{os.getcwd()}/resources/images", f))]
|
||||
# sort the files
|
||||
|
@ -18,7 +18,7 @@ async def get_images(current_user: Annotated[User, Depends(get_current_active_us
|
|||
return {"images": files}
|
||||
|
||||
@router.get("/{nom_image}")
|
||||
async def get_image(nom_image: str, current_user: Annotated[User, Depends(get_current_active_user)]):
|
||||
async def get_image(nom_image: str):
|
||||
return FileResponse(f"{os.getcwd()}/resources/images/{nom_image}")
|
||||
|
||||
@router.post("/")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue