Skip to content

Commit

Permalink
resources.path cannot return a dir with subdirs for py3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
VukW committed Aug 13, 2024
1 parent cedad96 commit 3ac8a74
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cli/medperf/web_ui/app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from importlib import resources
from pathlib import Path

import typer
from fastapi import FastAPI
Expand All @@ -20,15 +21,17 @@
web_app.include_router(mlcubes_router, prefix="/mlcubes")
web_app.include_router(yaml_fetch_router)

static_folder_path = Path(resources.files("medperf.web_ui")) / "static" # noqa
web_app.mount(
"/static",
StaticFiles(
directory=str(resources.path("medperf.web_ui", "static")),
directory=static_folder_path,
)
)

web_app.add_exception_handler(Exception, custom_exception_handler)


@web_app.get("/", include_in_schema=False)
def read_root():
return RedirectResponse(url="/benchmarks/ui")
Expand Down

0 comments on commit 3ac8a74

Please sign in to comment.