Skip to content
Browse files
  • Loading branch information
ralsina committed Feb 21, 2017
1 parent f4ea4f4 commit b80e962d8bf2d72302ccee70b89c5f91e0338d80
Showing 1 changed file with 1 addition and 5 deletions.
@@ -298,12 +298,8 @@ def serve_static(self, environ, start_response):
p_uri = urlparse(uri)
f_path = os.path.join(['OUTPUT_FOLDER'], *[unquote(x) for x in p_uri.path.split('/')])

# mimetypes.guess_type can't handle query strings, so we need
# to strip the URI to only the path for mimetype guessing
stripped_uri = urlparse.urljoin(url, p_uri.path)

# ‘Pretty’ URIs and root are assumed to be HTML
mimetype = 'text/html' if uri.endswith('/') else mimetypes.guess_type(stripped_uri)[0] or 'application/octet-stream'
mimetype = 'text/html' if uri.endswith('/') else mimetypes.guess_type(p_uri.path)[0] or 'application/octet-stream'

if os.path.isdir(f_path):
if not p_uri.path.endswith('/'): # Redirect to avoid breakage

0 comments on commit b80e962

Please sign in to comment.