added a function to convert the step file from the
upload to an obj file for 3D comparison
This commit is contained in:
16
main.py
16
main.py
@@ -1,6 +1,7 @@
|
||||
import os
|
||||
import tempfile
|
||||
import uuid
|
||||
import subprocess
|
||||
|
||||
from fastapi import FastAPI, UploadFile, File, HTTPException
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
@@ -56,3 +57,18 @@ async def upload_file(file: UploadFile = File(...)):
|
||||
"content_type": file.content_type,
|
||||
"size_bytes": target.stat().st_size,
|
||||
}
|
||||
@app.post("/upload/{file_id}/convert")
|
||||
async def convert_obj(file_id: str):
|
||||
inpath = UPLOAD_DIR / Path(file_id)
|
||||
|
||||
#check for target
|
||||
|
||||
outpath = UPLOAD_DIR / Path(file_id).with_suffix(".obj")
|
||||
result = subprocess.run(["freecadcmd", "step_to_obj_headless.py", inpath, outpath])
|
||||
|
||||
return {
|
||||
"file_id": file_id,
|
||||
"inpath": inpath,
|
||||
"outpath": outpath,
|
||||
"status": result.__str__()
|
||||
}
|
||||
Reference in New Issue
Block a user