/
boris00043
/
semantic-papers
Обзор
Документация
Войти
/
boris00043
/
semantic-papers
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
angular
services/article-parser/src/views/_template.py
16 строк
525 B
Бредихин Борис Андреевич
initial
23 ноя 2024, 09:37
23 ноя 2024, 09:37
28b72ae
Код
Авторство
О чём код?
from fastapi import FastAPI, Request from fastapi.responses import HTMLResponse class TemplateView: template_path: str def __init__(self, templates) -> None: self.templates = templates def mount(self, app: FastAPI, path: str, methods: list[str] = ['get']): for i in methods: app.__getattribute__(i)(path, response_class=HTMLResponse)(self.__getattribute__(i)) async def get(self, request: Request): return self.templates.TemplateResponse(request, self.template_path)