refactor(ebook-search): simplify search and phrase matching
This commit is contained in:
@@ -3,9 +3,14 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from fastapi.templating import Jinja2Templates
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from fastapi import Request
|
||||
from fastapi.responses import HTMLResponse
|
||||
|
||||
PACKAGE_DIR = Path(__file__).resolve().parent
|
||||
TEMPLATE_DIR = PACKAGE_DIR / "templates"
|
||||
STATIC_DIR = PACKAGE_DIR / "static"
|
||||
@@ -21,3 +26,8 @@ def static_version(filename: str) -> int:
|
||||
|
||||
templates = Jinja2Templates(directory=TEMPLATE_DIR)
|
||||
templates.env.globals["static_version"] = static_version
|
||||
|
||||
|
||||
def error_response(request: Request, message: object) -> HTMLResponse:
|
||||
"""Render the shared error partial for a failed UI request."""
|
||||
return templates.TemplateResponse(request, "partials/error.html", {"message": str(message)}, status_code=500)
|
||||
|
||||
Reference in New Issue
Block a user