@@ -34,8 +34,13 @@ def index(request, *args, **kwargs):
if path.endswith(u'/'):
path += u'index.html'
fullpath = os.path.join(STATIC_ROOT, path)
try:
# Junk URLs in production (Python 3.5) are causing UnicodeEncodeErrors
# here. Can't reproduce in development in Python 3.9 - only Python 2.7.
if not os.path.exists(fullpath):
return handler404(request)
except UnicodeEncodeError:
content_type, _ = mimetypes.guess_type(path)
if content_type != 'text/html':
return HttpResponse(open(fullpath, 'rb'), content_type)