Skip to content

Commit

Permalink
fix: check if its file before fetching
Browse files Browse the repository at this point in the history
  • Loading branch information
pateljannat committed Dec 6, 2024
1 parent 726ae8a commit 463a1d8
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lms/page_renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,11 @@ def render(self):
if not extension:
path = f"{path}.html"

f = open(path, "rb")
response = Response(
wrap_file(frappe.local.request.environ, f), direct_passthrough=True
)
response.mimetype = mimetypes.guess_type(path)[0]
return response
# check if path exists and is actually a file and not a folder
if os.path.exists(path) and os.path.isfile(path):
f = open(path, "rb")
response = Response(
wrap_file(frappe.local.request.environ, f), direct_passthrough=True
)
response.mimetype = mimetypes.guess_type(path)[0]
return response

0 comments on commit 463a1d8

Please sign in to comment.