fix serving binary files on windows
This commit is contained in:
parent
2f44899521
commit
503169ce76
|
@ -203,13 +203,15 @@ class LookupResource(resource.Resource, component.Component):
|
|||
request.path = path
|
||||
return self
|
||||
|
||||
def render(self, request):
|
||||
def render(self, request):
|
||||
log.debug("Requested path: '%s'", request.path)
|
||||
for lookup in self.directories:
|
||||
if request.path in os.listdir(lookup):
|
||||
path = os.path.join(lookup, request.path)
|
||||
path = os.path.join(lookup, request.path)
|
||||
log.debug("Serving path: '%s'", path)
|
||||
mime_type = mimetypes.guess_type(path)
|
||||
request.setHeader("content-type", mime_type[0])
|
||||
return open(path).read()
|
||||
return open(path, "rb").read()
|
||||
request.setResponseCode(http.NOT_FOUND)
|
||||
return "<h1>404 - Not Found</h1>"
|
||||
|
||||
|
|
Loading…
Reference in New Issue