blob: 52af9e86bfbc95ce4f44420c94de976dcd806385 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
"""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",
)
async def login(request: Request) -> Response:
"""Render the PIN login page."""
return templates.TemplateResponse(
request,
"login.html",
{},
media_type="text/html; charset=utf-8",
)
|