feat: add common view module
This commit is contained in:
@@ -6,16 +6,18 @@ from fastapi.responses import HTMLResponse, RedirectResponse
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from fastapi.templating import Jinja2Templates
|
||||
|
||||
from gallery.easel.route.view.weather.util import TagType, TagUtil
|
||||
from gallery.sketch.schedule.api import ScheduleApi
|
||||
from gallery.version import __version__
|
||||
|
||||
from ..common.util import TagType, TagUtil
|
||||
from .filters import timedelta_format
|
||||
|
||||
|
||||
def mount(app: FastAPI):
|
||||
base_dir = Path(__file__).parent
|
||||
app.mount(
|
||||
"/schedule/static", StaticFiles(directory=base_dir / "static"), name="static"
|
||||
)
|
||||
app.mount("/static/schedule", StaticFiles(directory=base_dir / "static"))
|
||||
templates = Jinja2Templates(directory=base_dir / "templates")
|
||||
templates.env.filters["timedelta_format"] = timedelta_format
|
||||
|
||||
@app.get("/schedule", response_class=HTMLResponse)
|
||||
async def get_schedule_list(request: Request):
|
||||
@@ -25,6 +27,7 @@ def mount(app: FastAPI):
|
||||
request=request,
|
||||
name="index.html",
|
||||
context={
|
||||
"version": __version__,
|
||||
"channels": channels,
|
||||
},
|
||||
)
|
||||
@@ -45,6 +48,7 @@ def mount(app: FastAPI):
|
||||
request=request,
|
||||
name="schedule.html",
|
||||
context={
|
||||
"version": __version__,
|
||||
"tag_util": TagUtil,
|
||||
"datetime": datetime,
|
||||
"response": response,
|
||||
|
||||
Reference in New Issue
Block a user