andreagalle commited on
Commit
6b9a605
·
1 Parent(s): 2d84f49

add some debug prints to check dir exists

Browse files
Files changed (1) hide show
  1. main.py +12 -2
main.py CHANGED
@@ -51,17 +51,27 @@ async def upload_zip(file: UploadFile = File(...)):
51
  ]
52
 
53
  try:
54
- subprocess.run(command, check=True)
 
 
55
  except subprocess.CalledProcessError as e:
 
56
  raise HTTPException(status_code=500, detail=f"3D model generation failed: {str(e)}")
57
 
 
 
 
58
  # Find the .glb file in the output directory
59
  glb_files = [os.path.join(output_dir, f) for f in os.listdir(output_dir) if f.endswith('.glb')]
60
  if not glb_files:
61
- raise HTTPException(status_code=500, detail="No .glb file generated")
62
 
63
  glb_file_path = glb_files[0]
64
 
 
 
 
 
65
  # Return the .glb file as a response
66
  return FileResponse(glb_file_path, media_type='application/octet-stream', filename=os.path.basename(glb_file_path))
67
 
 
51
  ]
52
 
53
  try:
54
+ result = subprocess.run(command, check=True, capture_output=True, text=True)
55
+ print("Subprocess output:", result.stdout)
56
+ print("Subprocess error:", result.stderr)
57
  except subprocess.CalledProcessError as e:
58
+ print("Subprocess failed with error:", e.stderr)
59
  raise HTTPException(status_code=500, detail=f"3D model generation failed: {str(e)}")
60
 
61
+ # Debug: List files in the output directory
62
+ print("Files in output directory:", os.listdir(output_dir))
63
+
64
  # Find the .glb file in the output directory
65
  glb_files = [os.path.join(output_dir, f) for f in os.listdir(output_dir) if f.endswith('.glb')]
66
  if not glb_files:
67
+ raise HTTPException(status_code=500, detail=f"No .glb file generated in {output_dir}")
68
 
69
  glb_file_path = glb_files[0]
70
 
71
+ # Debug: Check if the file exists
72
+ if not os.path.exists(glb_file_path):
73
+ raise HTTPException(status_code=500, detail=f"File {glb_file_path} does not exist")
74
+
75
  # Return the .glb file as a response
76
  return FileResponse(glb_file_path, media_type='application/octet-stream', filename=os.path.basename(glb_file_path))
77