Files

27 lines
642 B
Python
Raw Permalink Normal View History

from contextlib import asynccontextmanager
from fastapi import FastAPI
from config import settings
from engine.loader import init_engine
from api.detect import router as detect_router
from api.health import router as health_router
from api.model import router as model_router
@asynccontextmanager
async def lifespan(app: FastAPI):
init_engine(settings.model_path, settings.runtime)
yield
app = FastAPI(
title="明析推理服务",
version="1.0.0",
lifespan=lifespan,
)
app.include_router(detect_router, prefix="/api")
app.include_router(health_router, prefix="/api")
app.include_router(model_router, prefix="/api")