Handle root index autoserving.

This commit is contained in:
Sergio Martínez Portela 2023-09-19 23:40:12 +02:00
parent 7cc2407846
commit 12b5e31e49

View File

@ -61,6 +61,8 @@ class Server(http.server.SimpleHTTPRequestHandler):
self.end_headers() self.end_headers()
path = self.path path = self.path
if path.strip('/') == '':
path = '/index.html'
if os.path.isdir(path.strip('/')): if os.path.isdir(path.strip('/')):
path = path.strip('/') + '/index.html' path = path.strip('/') + '/index.html'
with open(path.strip('/'), 'rb') as f: with open(path.strip('/'), 'rb') as f: