refactor(easel): add view root module

This commit is contained in:
2026-06-24 11:44:50 +03:00
parent d9129a4947
commit 4dee16ef7e
5 changed files with 44 additions and 40 deletions

View File

@@ -1,11 +1,11 @@
from fastapi import APIRouter, Depends
from .common import router as common_router
from .root import router as root_router
from .schedule import router as schedule_router
from .translation import set_language
from .weather import router as weather_router
router = APIRouter(tags=["view"], dependencies=[Depends(set_language)])
router.include_router(common_router)
router.include_router(root_router)
router.include_router(weather_router)
router.include_router(schedule_router)

View File

@@ -1,36 +0,0 @@
from pathlib import Path
from typing import NamedTuple
from fastapi import APIRouter, Request
from fastapi.responses import HTMLResponse
from ..common.utils.template import build_templates
class Section(NamedTuple):
link: str
title: str
icon: str
SECTIONS = [
Section("weather", "Weather", "brightness-high"),
Section("schedule", "TV program", "tv"),
]
base_dir = Path(__file__).parent
router = APIRouter()
templates = build_templates()
@router.get("/", response_class=HTMLResponse)
async def get_section_list(request: Request):
return templates.TemplateResponse(
request=request,
name="root_index.html",
context={
"sections": SECTIONS,
},
)

View File

@@ -0,0 +1,36 @@
from pathlib import Path
from typing import NamedTuple
from fastapi import APIRouter, Request
from fastapi.responses import HTMLResponse
from ..common.utils.template import build_templates
class Section(NamedTuple):
link: str
title: str
icon: str
SECTIONS = [
Section("weather", "Weather", "brightness-high"),
Section("schedule", "TV program", "tv"),
]
base_dir = Path(__file__).parent
router = APIRouter()
templates = build_templates(Path(__file__).parent / "templates")
@router.get("/", response_class=HTMLResponse)
async def get_section_list(request: Request):
return templates.TemplateResponse(
request=request,
name="root_index.html",
context={
"sections": SECTIONS,
},
)

View File

@@ -2,6 +2,10 @@
set -e
cd "$(dirname $(dirname "$0"))" || exit
if [[ ! -f .env ]]; then
cp .env-base .env
fi
PYTHON_VERSION=3.12
poetry env use ${PYTHON_VERSION}
poetry install