StarfallBot/starfall/web/blueprints/main.py

42 lines
1.1 KiB
Python

from typing import Any
from flask import Blueprint, Flask, render_template
from flask_assets import Environment
from starfall.web.blueprints.base import BaseBlueprint
class MainBlueprint(BaseBlueprint):
def __init__(self, blueprint: Blueprint, assets: Environment, app: Flask) -> None:
super().__init__(blueprint, assets, app)
blueprint.add_url_rule("/", view_func=self.index)
blueprint.add_url_rule("/imprint", view_func=self.imprint)
self.app.register_error_handler(404, self.not_found)
def index(self):
self._log_access()
return render_template(
"home.jinja",
assets=self.assets,
route=self._route(),
date=self.date,
)
def imprint(self):
self._log_access()
return render_template(
"imprint.jinja",
assets=self.assets,
route=self._route(),
date=self.date,
)
def not_found(self, e: Any):
return render_template(
"404.jinja",
assets=self.assets,
route=self._route(),
date=self.date,
error=e,
), 404