init repo
This commit is contained in:
39
app/main.py
Normal file
39
app/main.py
Normal 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"}
|
||||
Reference in New Issue
Block a user