Files
doc_processer/app/main.py
liuyuanchuang aec030b071 feat: add log
2026-02-07 09:26:45 +08:00

50 lines
1.1 KiB
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
from app.core.logging_config import setup_logging
settings = get_settings()
# Initialize logging
setup_logging()
@asynccontextmanager
async def lifespan(app: FastAPI):
"""Application lifespan handler for startup/shutdown."""
# Startup: Load models
init_layout_detector()
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"}
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=settings.port)