diff --git a/main.py b/main.py index bf7a54f..526d4ae 100644 --- a/main.py +++ b/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__() + } \ No newline at end of file