feat: add compare, trends routes, embedder service, and phase5 tests
This commit is contained in:
+16
@@ -5,13 +5,16 @@ import os
|
||||
|
||||
from fastapi import FastAPI
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from starlette.staticfiles import StaticFiles as StarletteStaticFiles
|
||||
|
||||
from app.config import settings
|
||||
from app.database import engine
|
||||
from app.models import init_db
|
||||
from app.routes.admin import router as admin_router
|
||||
from app.routes.compare import router as compare_router
|
||||
from app.routes.pages import router as pages_router
|
||||
from app.routes.search import router as search_router
|
||||
from app.routes.trends import router as trends_router
|
||||
from app.routes.user import router as user_router
|
||||
|
||||
logging.basicConfig(
|
||||
@@ -49,11 +52,18 @@ def create_app() -> FastAPI:
|
||||
# 静态文件
|
||||
app.mount("/static", StaticFiles(directory="app/static"), name="static")
|
||||
|
||||
# Phase 5: 论文图片静态服务
|
||||
papers_images_dir = os.path.join("data", "papers")
|
||||
os.makedirs(papers_images_dir, exist_ok=True)
|
||||
app.mount("/papers", StaticFiles(directory=papers_images_dir), name="papers")
|
||||
|
||||
# 路由
|
||||
app.include_router(pages_router)
|
||||
app.include_router(admin_router)
|
||||
app.include_router(search_router)
|
||||
app.include_router(user_router)
|
||||
app.include_router(trends_router)
|
||||
app.include_router(compare_router)
|
||||
|
||||
# 调度器(Phase 4)
|
||||
@app.on_event("startup")
|
||||
@@ -61,6 +71,12 @@ def create_app() -> FastAPI:
|
||||
from app.services.scheduler import start_scheduler
|
||||
start_scheduler()
|
||||
|
||||
# Phase 5: 初始化 ChromaDB
|
||||
@app.on_event("startup")
|
||||
async def _init_chroma():
|
||||
from app.services.embedder import init_chroma
|
||||
init_chroma()
|
||||
|
||||
@app.on_event("shutdown")
|
||||
async def _stop_scheduler():
|
||||
from app.services.scheduler import stop_scheduler
|
||||
|
||||
Reference in New Issue
Block a user