simplify DB query

This commit is contained in:
JeLuF 2023-08-08 18:48:08 +02:00
parent 01dde9d23a
commit e828a72b08

View File

@ -94,11 +94,10 @@ def init():
def get_image(image_path: str, db: Session = Depends(get_db)):
from easydiffusion.easydb.mappings import Image
image_path = str(abspath(image_path))
amount = len(db.query(Image).filter(Image.path == image_path).all())
if amount > 0:
try:
image = db.query(Image).filter(Image.path == image_path).first()
return FileResponse(image.path)
else:
except Exception as e:
raise HTTPException(status_code=404, detail="Image not found")
@server_api.get("/all_images")