Files
doc_processer/app/main.py
liuyuanchuang 874fd383cc init repo
2025-12-29 17:34:58 +08:00

40 lines
932 B
Python

"""FastAPI application entry point."""
from contextlib import asynccontextmanager
from fastapi import FastAPI
from app.api.v1.router import api_router
from app.core.config import get_settings
from app.core.dependencies import init_layout_detector
settings = get_settings()
@asynccontextmanager
async def lifespan(app: FastAPI):
"""Application lifespan handler for startup/shutdown."""
# Startup: Load models
init_layout_detector(model_path=settings.doclayout_model_path)
yield
# Shutdown: Cleanup happens automatically
app = FastAPI(
title="DocProcesser API",
description="Document processing API - Image to LaTeX/Markdown/MathML and Markdown to DOCX",
version="0.1.0",
lifespan=lifespan,
)
# Include API router
app.include_router(api_router, prefix=settings.api_prefix)
@app.get("/health")
async def health_check():
"""Health check endpoint."""
return {"status": "healthy"}