From dd4ad06bf555ebaeb54af1d70dfe12f0e872a8f5 Mon Sep 17 00:00:00 2001 From: cjw <792430652@qq.com> Date: Mon, 16 Feb 2026 01:07:44 +0800 Subject: [PATCH] deving --- src/api/routes.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/api/routes.py b/src/api/routes.py index e7c1350..52739ec 100644 --- a/src/api/routes.py +++ b/src/api/routes.py @@ -37,8 +37,8 @@ async def read_root(request: Request): """主页面""" from fastapi.templating import Jinja2Templates import os - # 使用绝对路径确保模板目录正确 - templates_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), "templates") + # 简化路径配置,直接使用当前工作目录下的templates文件夹 + templates_dir = os.path.join(os.getcwd(), "templates") templates = Jinja2Templates(directory=templates_dir) return templates.TemplateResponse("index.html", { "request": request, @@ -198,7 +198,8 @@ async def history_page(request: Request): """历史记录页面""" from fastapi.templating import Jinja2Templates import os - templates_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), "templates") + # 简化路径配置,直接使用当前工作目录下的templates文件夹 + templates_dir = os.path.join(os.getcwd(), "templates") templates = Jinja2Templates(directory=templates_dir) return templates.TemplateResponse("history.html", { "request": request, @@ -217,7 +218,8 @@ async def result_page(request: Request, task_id: str): from fastapi.templating import Jinja2Templates import os - templates_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), "templates") + # 简化路径配置,直接使用当前工作目录下的templates文件夹 + templates_dir = os.path.join(os.getcwd(), "templates") templates = Jinja2Templates(directory=templates_dir) return templates.TemplateResponse("result.html", { "request": request,