From 10c5d3d34775440b4d1ab31a5404abe199f79cd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E8=88=AA=E5=AE=87?= <3364451258@qq.com> Date: Sat, 11 Jul 2026 19:57:30 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20Web=20=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E7=95=8C=E9=9D=A2=EF=BC=88Vue=203=20SPA=20=E5=8D=95?= =?UTF-8?q?=E6=96=87=E4=BB=B6=EF=BC=89+=20/admin=20=E6=8C=82=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/server/app.py | 7 +++ src/web/index.html | 147 +++++++++++++++++++++++++++++++++++++++++++++ tests/test_api.py | 13 ++++ 3 files changed, 167 insertions(+) create mode 100644 src/web/index.html diff --git a/src/server/app.py b/src/server/app.py index b455be0..a623bd4 100644 --- a/src/server/app.py +++ b/src/server/app.py @@ -61,8 +61,15 @@ async def lifespan(app: FastAPI): yield +from fastapi.staticfiles import StaticFiles + app = FastAPI(title="md-vector-db", version="0.1.0", lifespan=lifespan) +# 挂载 Web 管理界面 +web_dir = Path(__file__).parent.parent / "web" +if web_dir.exists(): + app.mount("/admin", StaticFiles(directory=str(web_dir), html=True), name="admin") + # CORS 中间件 app.add_middleware( CORSMiddleware, diff --git a/src/web/index.html b/src/web/index.html new file mode 100644 index 0000000..4e9423f --- /dev/null +++ b/src/web/index.html @@ -0,0 +1,147 @@ + + +
+ + +{{ (r.content||'').substring(0,300) }}{{ (r.content||'').length > 300 ? '...' : '' }}
+ {{ ingestResult }}
+| 名称 | Chunks |
|---|---|
| {{ c.name }} | {{ c.count }} |
{{ JSON.stringify(health.checks, null, 2) }}
+