mirror of
https://github.com/easydiffusion/easydiffusion.git
synced 2025-06-20 18:08:00 +02:00
simplify DB query
This commit is contained in:
parent
01dde9d23a
commit
e828a72b08
@ -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")
|
||||
|
Loading…
x
Reference in New Issue
Block a user