pseudotheos commited on
Commit
ec8ffd1
·
1 Parent(s): 27a0b3c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -267,7 +267,10 @@ app.add_middleware(
267
  async def get_image(
268
  job_id: int = Form(...)
269
  ):
270
- image_path = f"/tmp/{job_id}_output_{image.filename}"
 
 
 
271
  with open(image_path, "rb") as file:
272
  generated_image = file.read()
273
 
@@ -307,7 +310,7 @@ async def generate_image(
307
  if generated_image is None:
308
  return "Failed to generate image"
309
 
310
- output_image_path = f"/tmp/{job_id}_output_{image.filename}"
311
  with open(output_image_path, "wb") as output_image:
312
  output_image.write(generated_image)
313
 
 
267
  async def get_image(
268
  job_id: int = Form(...)
269
  ):
270
+ image_path = f"/tmp/{job_id}_output.png"
271
+ if !os.path.isfile(image_path):
272
+ return None
273
+
274
  with open(image_path, "rb") as file:
275
  generated_image = file.read()
276
 
 
310
  if generated_image is None:
311
  return "Failed to generate image"
312
 
313
+ output_image_path = f"/tmp/{job_id}_output.png"
314
  with open(output_image_path, "wb") as output_image:
315
  output_image.write(generated_image)
316