Пример #1
0
    async def get(self, request: Request) -> _TemplateResponse:
        context = {"request": request}

        anime = []
        for i in Anime.select():
            try:
                fansub = Fansub.get(id=i.fansub_id)
                fansub_name = fansub.name
            except Fansub.DoesNotExist:
                fansub_name = "N.A"

            anime.append({
                "name":
                i.name,
                "url": [{
                    "name": parts.split(";")[0],
                    "href": parts.split(";")[1]
                } for parts in i.url.split(",")] if len(i.url) else [],
                "fansub":
                fansub_name
            })

        context.update({"anime": anime})

        return templates.TemplateResponse("home.html", context)
Пример #2
0
    def __response(self,
                   request: Request,
                   extra: Optional[dict] = None) -> _TemplateResponse:
        context = {"request": request, "anime": Anime.select()}

        if extra:
            context.update(extra)

        return templates.TemplateResponse("anime/backend.html", context)