Spaces:
Paused
Paused
andreagalle commited on
Commit ·
2d84f49
1
Parent(s): 29d4d33
first try to get the .glb file
Browse files
main.py
CHANGED
|
@@ -1,13 +1,11 @@
|
|
| 1 |
-
# app.py
|
| 2 |
import os
|
| 3 |
import shutil
|
| 4 |
import tempfile
|
| 5 |
import zipfile
|
| 6 |
from fastapi import FastAPI, File, UploadFile, HTTPException
|
| 7 |
-
from fastapi.responses import
|
| 8 |
from typing import List
|
| 9 |
import subprocess
|
| 10 |
-
# import torch
|
| 11 |
|
| 12 |
app = FastAPI()
|
| 13 |
|
|
@@ -57,7 +55,15 @@ async def upload_zip(file: UploadFile = File(...)):
|
|
| 57 |
except subprocess.CalledProcessError as e:
|
| 58 |
raise HTTPException(status_code=500, detail=f"3D model generation failed: {str(e)}")
|
| 59 |
|
| 60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
if __name__ == '__main__':
|
| 63 |
import uvicorn
|
|
|
|
|
|
|
| 1 |
import os
|
| 2 |
import shutil
|
| 3 |
import tempfile
|
| 4 |
import zipfile
|
| 5 |
from fastapi import FastAPI, File, UploadFile, HTTPException
|
| 6 |
+
from fastapi.responses import FileResponse
|
| 7 |
from typing import List
|
| 8 |
import subprocess
|
|
|
|
| 9 |
|
| 10 |
app = FastAPI()
|
| 11 |
|
|
|
|
| 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 |
|
| 68 |
if __name__ == '__main__':
|
| 69 |
import uvicorn
|