summaryrefslogtreecommitdiff
path: root/src/ollama_web/app.py
diff options
context:
space:
mode:
authortanaka takashi <isazaka@gmail.com>2026-06-26 23:54:17 +0900
committertanaka takashi <isazaka@gmail.com>2026-06-26 23:54:17 +0900
commit3a9e8e18df4c596360da54000f65e1bebc6039c2 (patch)
tree0c6dc5fd75cc8f751ca6d7dca01c7e7b5fb3c9f5 /src/ollama_web/app.py
parenta296c2c3a294648c04286a5c027deddbbdc8d5ae (diff)
MCP機能追加
Diffstat (limited to 'src/ollama_web/app.py')
-rw-r--r--src/ollama_web/app.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/ollama_web/app.py b/src/ollama_web/app.py
index 946d280..d0b85d4 100644
--- a/src/ollama_web/app.py
+++ b/src/ollama_web/app.py
@@ -2,6 +2,7 @@
from __future__ import annotations
+import logging
from pathlib import Path
from starlette.applications import Starlette
@@ -15,6 +16,7 @@ from .config import settings
from .middleware import SecurityHeadersMiddleware
from .routes import auth as auth_route
from .routes import chat as chat_route
+from .routes import mcp as mcp_route
from .routes import models as models_route
from .routes import pages as pages_route
from .routes import sessions as sessions_route
@@ -25,6 +27,17 @@ _STATIC_DIR = Path(__file__).resolve().parent / "static"
def create_app() -> Starlette:
"""Build and return the configured Starlette application."""
+ # Ensure application logs are written alongside uvicorn access logs.
+ log_path = Path(settings.data_dir).resolve().parent / "server.log"
+ log_path.parent.mkdir(parents=True, exist_ok=True)
+ handler = logging.FileHandler(str(log_path), encoding="utf-8")
+ handler.setFormatter(
+ logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
+ )
+ root = logging.getLogger()
+ root.setLevel(logging.INFO)
+ root.addHandler(handler)
+
routes = [
Route("/login", pages_route.login, name="login_page"),
Route("/api/auth/login", auth_route.login, methods=["POST"], name="auth_login"),
@@ -77,6 +90,13 @@ def create_app() -> Starlette:
methods=["DELETE"],
name="clear_messages",
),
+ Route("/api/mcp/servers", mcp_route.get_servers, methods=["GET"], name="mcp_servers"),
+ Route(
+ "/api/mcp/servers",
+ mcp_route.put_servers,
+ methods=["PUT"],
+ name="mcp_servers_update",
+ ),
Mount("/static", app=StaticFiles(directory=str(_STATIC_DIR)), name="static"),
]
@@ -99,4 +119,4 @@ def create_app() -> Starlette:
return app
-app = create_app()
+app = create_app() \ No newline at end of file