From e0868208513806a5fa5e1b13a44bd466946f6838 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B4=9B=E6=B0=B4=E5=B1=85=E5=AE=A4?= Date: Thu, 27 Apr 2023 22:19:06 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Support=20for=20Jinja2=20template?= =?UTF-8?q?=20preview?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/services/template/services.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/services/template/services.py b/core/services/template/services.py index dd61d7c..546ad7b 100644 --- a/core/services/template/services.py +++ b/core/services/template/services.py @@ -182,7 +182,7 @@ class TemplatePreviewer(BaseService, load=application_config.webserver.enable an @self.web_app.get("/preview/{path:path}") async def preview_template(path: str, key: Optional[str] = None): # pylint: disable=W0612 # 如果是 /preview/ 开头的静态文件,直接返回内容。比如使用相对链接 ../ 引入的静态资源 - if not path.endswith(".html"): + if not (path.endswith(".html") ^ path.endswith(".jinja2")): full_path = self.template_service.template_dir / path if not full_path.is_file(): raise HTTPException(status_code=404, detail=f"Template '{path}' not found")