Server: actually return MIME type

The original paths being provided had a tailing slash, and so everything was returning as "application/octet-stream" (at least on Windows)
This commit is contained in:
MinchinWeb 2021-10-02 09:19:56 -06:00
commit 1b52185ece

View file

@ -91,7 +91,9 @@ class ComplexHTTPRequestHandler(server.SimpleHTTPRequestHandler):
def guess_type(self, path):
"""Guess at the mime type for the specified file.
"""
mimetype = server.SimpleHTTPRequestHandler.guess_type(self, path)
# strip trailing slash
path = path.rstrip().strip("/").strip(os.sep)
mimetype = super().guess_type(path)
# If the default guess is too generic, try the python-magic library
if mimetype == 'application/octet-stream' and magic_from_file: