Skip to content

Commit

Permalink
Minor changes: Removed unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
skelly authored and lil-skelly committed Sep 4, 2024
1 parent 57c8bd3 commit 3d05dd2
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions src/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,15 @@ def list_directory(self, path):
return None

file_list.sort(key=lambda a: a.lower())
r = []

try:
displaypath = urllib.parse.unquote(self.path, errors="surrogatepass")
except UnicodeDecodeError:
displaypath = urllib.parse.unquote(self.path)

displaypath = html.escape(displaypath, quote=False)

contents = []

enc = sys.getfilesystemencoding()

for name in file_list:
fullname = os.path.join(path, name)
display_name = f"http://{self.headers['Host']}{self.path}{fullname}"
r.append(html.escape(display_name, quote=False))
display_name = f"http://{self.headers['Host']}{self.path}{name}"
contents.append(html.escape(display_name, quote=False))

encoded = "\n".join(r).encode(enc, "surrogateescape")
encoded = "\n".join(contents).encode(enc, "surrogateescape")
f = io.BytesIO()
f.write(encoded)
f.seek(0)
Expand All @@ -73,4 +65,4 @@ def start_server(bind, port):
protocol="HTTP/1.1", # permit keep-alive connections
port=port,
bind=bind,
)
)

0 comments on commit 3d05dd2

Please sign in to comment.