if input image file is not configured, return code 200

This commit is contained in:
Qing
2024-11-23 11:03:22 +08:00
parent 24764bd8bb
commit cfad51634b

View File

@@ -186,7 +186,7 @@ class Api:
file_to_write = Path(file.filename) file_to_write = Path(file.filename)
if not file_to_write.is_file(): if not file_to_write.is_file():
return return
origin_image_bytes = file.file.read() origin_image_bytes = file.file.read()
with open(self.config.output_dir / file_to_write.name, "wb") as fw: with open(self.config.output_dir / file_to_write.name, "wb") as fw:
fw.write(origin_image_bytes) fw.write(origin_image_bytes)
@@ -241,7 +241,10 @@ class Api:
) )
def api_input_image(self) -> FileResponse: def api_input_image(self) -> FileResponse:
if self.config.input and self.config.input.is_file(): if self.config.input is None:
raise HTTPException(status_code=200, detail="No input image configured")
if self.config.input.is_file():
return FileResponse(self.config.input) return FileResponse(self.config.input)
raise HTTPException(status_code=404, detail="Input image not found") raise HTTPException(status_code=404, detail="Input image not found")