feat: jinja template for cards

This commit is contained in:
2026-07-14 16:18:01 +02:00
parent 34fadcf6f6
commit f229b42dbc
12 changed files with 89 additions and 105 deletions
+18 -4
View File
@@ -8,6 +8,7 @@ import gunicorn.app.base
import tortoise
from app import PKG_NAME
from app.lang import get_lang
from app.models import Task
if typing.TYPE_CHECKING:
@@ -22,6 +23,7 @@ class Server(gunicorn.app.base.BaseApplication):
self.debug = params.debug
self.workers = params.workers
self.timeout = params.timeout
self.app_url = params.app_url
self.app = flask.Flask(
PKG_NAME, static_folder="dist/assets", template_folder="dist"
)
@@ -36,11 +38,23 @@ class Server(gunicorn.app.base.BaseApplication):
super().__init__()
def register_routes(self) -> typing.Self:
@self.app.route("/", defaults={"_": ""})
@self.app.route("/<_>")
@self.app.route("/", defaults={"path": ""})
@self.app.route("/<path>")
@self.limiter.exempt
def index(_: str) -> str:
return flask.render_template("index.html")
def index(path: str) -> str:
locale = "en"
if "lang" in flask.request.cookies:
locale = flask.request.cookies["lang"]
if "lang" in flask.request.args:
locale = flask.request.args["lang"]
return flask.render_template(
"index.html",
title=("Tout Doux" if not len(path) else f"Tout Doux - {path}"),
app_url=self.app_url,
path=path,
locale=locale,
lang=lambda key: get_lang(locale, key),
)
@self.app.route("/api/lists/<list_name>/tasks", methods=["GET"])
async def get_tasks(list_name: str) -> list: