StarfallBot/starfall/web/blueprints/public/main.py

31 lines
872 B
Python

from typing import Any
from flask import Blueprint, Flask, render_template
from flask_assets import Environment
from flask_babel import get_locale
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)
self.app.register_error_handler(404, self.not_found)
def index(self):
self._log_access()
return render_template(
"public/home.jinja",
bp=self,
lang=get_locale(),
)
def not_found(self, e: Any):
self.error: Any = e
return render_template(
"errors/not_found.jinja",
bp=self,
lang=get_locale(),
), 404