init repo

This commit is contained in:
liuyuanchuang
2025-12-29 17:34:58 +08:00
commit 874fd383cc
36 changed files with 2641 additions and 0 deletions

39
app/main.py Normal file
View File

@@ -0,0 +1,39 @@
"""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"}