Skip to content
Permalink
Browse files

Don't use bytes for headers, it breaks in python3

  • Loading branch information
ralsina committed Jul 1, 2015
1 parent 685239d commit 62609d7113fc110db78ad8592dbb7c008702f9a1
Showing with 5 additions and 5 deletions.
  1. +5 −5 nikola/plugins/command/auto/__init__.py
@@ -237,23 +237,23 @@ def serve_static(self, environ, start_response):
uri = wsgiref.util.request_uri(environ)
p_uri = urlparse(uri)
f_path = os.path.join(self.site.config['OUTPUT_FOLDER'], *p_uri.path.split('/'))
mimetype = mimetypes.guess_type(uri)[0] or b'text/html'
mimetype = mimetypes.guess_type(uri)[0] or 'text/html'

if os.path.isdir(f_path):
f_path = os.path.join(f_path, self.site.config['INDEX_FILE'])

if p_uri.path == '/robots.txt':
start_response(b'200 OK', [(b'Content-type', 'txt/plain')])
start_response('200 OK', [('Content-type', 'txt/plain')])
return '''User-Agent: *\nDisallow: /\n'''
elif os.path.isfile(f_path):
with open(f_path) as fd:
start_response(b'200 OK', [(b'Content-type', mimetype)])
start_response('200 OK', [('Content-type', mimetype)])
return self.inject_js(mimetype, fd.read())
elif p_uri.path == '/livereload.js':
with open(LRJS_PATH) as fd:
start_response(b'200 OK', [(b'Content-type', mimetype)])
start_response('200 OK', [('Content-type', mimetype)])
return self.inject_js(mimetype, fd.read())
start_response(b'404 ERR', [])
start_response('404 ERR', [])
return self.inject_js('text/html', ERROR_N.format(404).format(uri))

def inject_js(self, mimetype, data):

0 comments on commit 62609d7

Please sign in to comment.
You can’t perform that action at this time.