From 59c9dfcf6bb5e336f7d5912f2c93727a71afd074 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Mart=C3=ADnez=20Portela?= Date: Sat, 16 Sep 2023 18:41:31 +0200 Subject: [PATCH] Fix autoserving of directory indexes. --- scripts/autoserve.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/autoserve.py b/scripts/autoserve.py index 4c7739e..deb2e0c 100644 --- a/scripts/autoserve.py +++ b/scripts/autoserve.py @@ -60,11 +60,14 @@ class Server(http.server.SimpleHTTPRequestHandler): # send response headers self.end_headers() - with open(self.path.strip('/'), 'rb') as f: + path = self.path + if os.path.isdir(path.strip('/')): + path = path.strip('/') + '/index.html' + with open(path.strip('/'), 'rb') as f: # send the body of the response self.wfile.write(f.read()) - if not self.path.endswith('.html'): + if not path.endswith('.html'): return else: # Append update waiter