Skip to content

Commit

Permalink
clearer paths
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverlambson committed Aug 21, 2024
1 parent c6d8244 commit c9b5725
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions boredcharts/webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,20 @@
from boredcharts.jinja import figure, md_to_html, row

module_root = Path(__file__).parent.absolute()
Path(module_root / "static" / "plotlyjs.min.js").write_text(get_plotlyjs())
static_root = module_root / "static"
templates_root = module_root / "templates"
pages_root = module_root / "templates" / "pages"

Path(static_root / "plotlyjs.min.js").write_text(get_plotlyjs())

app = FastAPI()
app.mount(
"/static",
StaticFiles(directory=module_root / "static"),
StaticFiles(directory=static_root),
"static",
)
templates = Jinja2Templates(
directory=module_root / "templates",
directory=templates_root,
env=Environment(
trim_blocks=True,
lstrip_blocks=True,
Expand All @@ -31,7 +36,7 @@
templates.env.globals["reports"] = [
{"name": f.stem}
for f in sorted(
(module_root / "templates" / "pages").glob("*.md"),
pages_root.glob("*.md"),
reverse=True,
)
]
Expand Down

0 comments on commit c9b5725

Please sign in to comment.