diff --git a/src/cli/main.py b/src/cli/main.py index 4944172..b161211 100644 --- a/src/cli/main.py +++ b/src/cli/main.py @@ -72,7 +72,8 @@ def search(query: str, top_k: int = 10): @app.command() def serve(port: int = 8000): """启动 HTTP 服务.""" - typer.echo(f"🚀 启动服务: http://0.0.0.0:{port}") + typer.echo(f"🚀 启动服务: http://localhost:{port}") + typer.echo(f"📖 API 文档: http://localhost:{port}/docs") uvicorn.run("src.server.app:app", host="0.0.0.0", port=port, reload=False) diff --git a/src/server/app.py b/src/server/app.py index 338fcce..09ecffc 100644 --- a/src/server/app.py +++ b/src/server/app.py @@ -84,6 +84,13 @@ app = FastAPI( ) +@app.get("/") +def root(): + """根路径重定向到 API 文档.""" + from fastapi.responses import RedirectResponse + return RedirectResponse(url="/docs") + + @app.get("/api/v1/health") def health(): return {"status": "ok"}