From 05bf531e330f4209b10315869f4d8bd5e3f08ef4 Mon Sep 17 00:00:00 2001 From: Massimo Di Pierro Date: Sun, 2 Jun 2024 14:46:55 -0700 Subject: [PATCH] fixes issue #855, thanks kszys --- apps/showcase/__init__.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/showcase/__init__.py b/apps/showcase/__init__.py index 13f46ef2..9c3999dd 100644 --- a/apps/showcase/__init__.py +++ b/apps/showcase/__init__.py @@ -62,12 +62,13 @@ def show(name): path = name name = name.rstrip("/0123456789") data = [] - filename = f"apps/showcase/{name}.md" + here = os.path.dirname(__file__) + filename = f"{here}/{name}.md" if os.path.exists(filename): with open(filename) as stream: metadata = stream.read().strip() data.append({"name": f"{name}.md", "content": metadata, "language": "markdown"}) - filename = f"apps/showcase/{name}.py" + filename = f"{here}/{name}.py" if not os.path.exists(filename): raise HTTP(404) with open(filename) as stream: @@ -75,7 +76,7 @@ def show(name): data.append({"name": f"{name}.py", "content": controller, "language": "python"}) templates = re.compile(r"[/\w]+\.html").findall(controller) for template in templates: - with open(f"apps/showcase/templates/{template}") as stream: + with open(f"{here}/templates/{template}") as stream: content = stream.read().strip() data.append( { @@ -89,7 +90,7 @@ def show(name): if not other.startswith("."): continue filename = other[1:].replace(".", "/") + ".py" - with open(f"apps/showcase/{filename}") as stream: + with open(f"{here}/{filename}") as stream: content = stream.read().strip() data.append({"shortname": filename, "content": content, "language": "python"}) # drop the subfolder name