diff --git a/.gitignore b/.gitignore index 933a116e..93a6edea 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ wandb report.json benchmark_data debug_data +uploads # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/marker_server.py b/marker_server.py index 4387838d..58155949 100644 --- a/marker_server.py +++ b/marker_server.py @@ -14,12 +14,20 @@ from typing import Optional, Annotated import io -from fastapi import FastAPI, Body +from fastapi import FastAPI, Body, Form, File, UploadFile, HTTPException from marker.convert import convert_single_pdf from marker.models import load_all_models app_data = {} + +UPLOAD_DIRECTORY = "./uploads" # Directory to store uploaded files + +# Ensure the upload directory exists +if not os.path.exists(UPLOAD_DIRECTORY): + os.makedirs(UPLOAD_DIRECTORY) + + @asynccontextmanager async def lifespan(app: FastAPI): if app.state.LOCAL: @@ -33,10 +41,11 @@ async def lifespan(app: FastAPI): app = FastAPI(lifespan=lifespan) + @app.get("/") async def root(): return HTMLResponse( -""" + """

Marker API