GranularFireplace commited on
Commit
27d9f2a
·
verified ·
1 Parent(s): 00e11d1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -227,7 +227,8 @@ async def list_files():
227
  """List all uploaded files"""
228
  try:
229
  files = os.listdir(UPLOAD_DIR)
230
- return {"files": files}
 
231
  except Exception as e:
232
  logger.error(f"Error listing files: {str(e)}")
233
  raise HTTPException(
@@ -352,7 +353,7 @@ def convert_binary_to_image(binary_path: str, output_path: str, width: int):
352
 
353
  @app.get("/image/{file_name}")
354
  async def image(file_name: str):
355
- if os.path.exists(file_name):
356
  return FileResponse(file_name, media_type="image/png")
357
  return JSONResponse(content={"error": "Image not found"})
358
 
@@ -377,7 +378,7 @@ async def analyse_bin(file_name: str):
377
  result = predict_malware(img_array)
378
  return {
379
  **result,
380
- "image_location": str(temp_image)
381
  }
382
 
383
  except HTTPException as he:
 
227
  """List all uploaded files"""
228
  try:
229
  files = os.listdir(UPLOAD_DIR)
230
+ filtered_files = [file for file in files if not file.startswith('temp')]
231
+ return {"files": filtered_files}
232
  except Exception as e:
233
  logger.error(f"Error listing files: {str(e)}")
234
  raise HTTPException(
 
353
 
354
  @app.get("/image/{file_name}")
355
  async def image(file_name: str):
356
+ if os.path.exists(os.path.join(UPLOAD_DIR, file_name)):
357
  return FileResponse(file_name, media_type="image/png")
358
  return JSONResponse(content={"error": "Image not found"})
359
 
 
378
  result = predict_malware(img_array)
379
  return {
380
  **result,
381
+ "image_location": str(temp_image)[8:]
382
  }
383
 
384
  except HTTPException as he: