from fastapi import FastAPI, UploadFile, File from add_thickness import add_thickness_to_stl app = FastAPI() @app.post("/process_stl/") async def process_stl(file: UploadFile = File(...)): input_file_path = f"temp/{file.filename}" output_file_path = f"processed/{file.filename}" # 保存上传的文件 with open(input_file_path, 'wb') as buffer: buffer.write(file.file.read()) # 调用修改过的 add_thickness 函数 add_thickness_to_stl(input_file_path, output_file_path) # 返回处理后的文件 return FileResponse(output_file_path, headers={"Content-Disposition": f"attachment; filename={file.filename}"})