From d1cdc948ed7f1770db2f3d0e2f05c34bb9ba2094 Mon Sep 17 00:00:00 2001 From: jstzwj <1103870790@qq.com> Date: Fri, 6 Sep 2024 20:27:12 +0800 Subject: [PATCH] add html pages to package data --- olah/server.py | 4 +++- pyproject.toml | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/olah/server.py b/olah/server.py index 6441474..1a4f80a 100644 --- a/olah/server.py +++ b/olah/server.py @@ -161,8 +161,10 @@ async def lifespan(app: FastAPI): # ====================== # Application # ====================== +code_file_path = os.path.abspath(__file__) app = FastAPI(lifespan=lifespan, debug=False) -templates = Jinja2Templates(directory="static") +templates = Jinja2Templates(directory=os.path.join(os.path.dirname(code_file_path), "..", "static")) + class AppSettings(BaseSettings): # The address of the model controller. diff --git a/pyproject.toml b/pyproject.toml index c5f6378..6ce8df3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,5 +31,8 @@ olah-cli = "olah.server:cli" [tool.setuptools.packages.find] exclude = ["assets*", "benchmark*", "docs", "dist*", "playground*", "scripts*", "tests*"] +[tool.setuptools.package-data] +static = ["*.html"] + [tool.wheel] exclude = ["assets*", "benchmark*", "docs", "dist*", "playground*", "scripts*", "tests*"]