docker_mineru / app.py
marcosremar2's picture
fdfdffd
a217d36
raw
history blame
472 Bytes
from fastapi import FastAPI, UploadFile, File
from fastapi.responses import JSONResponse
from magic_pdf import MinerU
app = FastAPI()
model = MinerU(config_path="/root/magic-pdf.json")
@app.post("/extract")
async def extract(file: UploadFile = File(...)):
content = await file.read()
try:
result = model.extract(content)
return {"result": result}
except Exception as e:
return JSONResponse(status_code=500, content={"error": str(e)})