From f06bcf535901fe1632f82f19819c852875e188e3 Mon Sep 17 00:00:00 2001 From: Dita Aji Pratama Date: Mon, 3 Mar 2025 13:10:10 +0700 Subject: [PATCH] Ensure HTML path is a file, not a directory --- core/html.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/core/html.py b/core/html.py index d461af7..ed88585 100644 --- a/core/html.py +++ b/core/html.py @@ -1,4 +1,3 @@ -import sys import os class main: @@ -8,10 +7,10 @@ class main: def get_html(location): html_dict = {} - html_page_list = os.listdir( location ) + html_page_list = os.listdir(location) for html_page in html_page_list: - full_path = location + "/" + html_page - html_handle = open( full_path , 'r' ) - html_raw = html_handle.read() - html_dict[html_page] = html_raw + full_path = os.path.join(location, html_page) + if os.path.isfile(full_path): # Ensure it's a file, not a directory + with open(full_path, 'r') as html_handle: + html_dict[html_page] = html_handle.read() return html_dict