diff options
| author | tanaka takashi <isazaka@gmail.com> | 2026-06-23 18:37:46 +0900 |
|---|---|---|
| committer | tanaka takashi <isazaka@gmail.com> | 2026-06-23 18:37:46 +0900 |
| commit | 21b59cc1d0928dc04dcf5eac24470aaa05013b2d (patch) | |
| tree | 9888aa23aafea3907ce96eb958a06d4369dad86e /src/ollama_web/routes/pages.py | |
| parent | de0513e7cb0593b1aa141e367ff4da7156d6110f (diff) | |
基本機能実装
Diffstat (limited to 'src/ollama_web/routes/pages.py')
| -rw-r--r-- | src/ollama_web/routes/pages.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/ollama_web/routes/pages.py b/src/ollama_web/routes/pages.py new file mode 100644 index 0000000..8e1d084 --- /dev/null +++ b/src/ollama_web/routes/pages.py @@ -0,0 +1,27 @@ +"""Page routes rendering Jinja2 templates.""" + +from __future__ import annotations + +from pathlib import Path + +from starlette.requests import Request +from starlette.responses import Response +from starlette.templating import Jinja2Templates + +from ollama_web import llm + +_TEMPLATES_DIR = Path(__file__).resolve().parent.parent / "templates" +templates = Jinja2Templates(directory=str(_TEMPLATES_DIR)) + + +async def index(request: Request) -> Response: + """Render the chat page with the available model list.""" + host = request.app.state.settings.ollama_host + models = llm.list_models(host=host) + default_model = request.app.state.settings.default_model + return templates.TemplateResponse( + request, + "index.html", + {"models": models, "default_model": default_model}, + media_type="text/html; charset=utf-8", + ) |
