diff --git a/config.py b/config.py
index f549a78..444d332 100644
--- a/config.py
+++ b/config.py
@@ -1,4 +1,4 @@
-name="debweb 1.1.1"
+name="debweb 1.1.2"
proxied=False
addr="localhost"
diff --git a/main.py b/main.py
index 0a6e740..f56c76e 100644
--- a/main.py
+++ b/main.py
@@ -100,15 +100,18 @@ class WebServer:
resp = await f.read()
files = ""
- norm_path = file_path.replace('\\', '/')
- base_path = norm_path.replace(self.directory.replace('\\', '/'), '').strip('/')
+ base_path = os.path.relpath(file_path, self.directory).replace('\\', '/')
+ if base_path == '.':
+ base_path = ''
for item in sorted(os.listdir(file_path)):
item_path = os.path.join(file_path, item)
is_dir = os.path.isdir(item_path)
- rel_path = f"{base_path}/{item}" if base_path else item
- rel_path = rel_path.replace('\\', '/')
+ if base_path:
+ rel_path = f"{base_path}/{item}"
+ else:
+ rel_path = item
if is_dir:
rel_path += "/"
@@ -118,7 +121,9 @@ class WebServer:
modify_datetime = datetime.datetime.fromtimestamp(modify_time)
formatted_time = modify_datetime.strftime("%d.%m.%Y %H:%M:%S")
- files += f'{item} | {formatted_time}
\n'
+ rel_path_encoded = rel_path.replace(' ', '%20').replace('#', '%23')
+
+ files += f'{item} | {formatted_time}
\n'
resp = resp.replace("", files)
resp = resp.encode()
@@ -144,11 +149,18 @@ class WebServer:
)
writer.write(response.encode())
await writer.drain()
+
+ writer.close()
+ await writer.wait_closed()
+
return
await self.log(self.get_msg, addr, file_path)
await writer.drain()
+ writer.close()
+ await writer.wait_closed()
+
async def start(self) -> None:
server = await asyncio.start_server(