Skip to content

Commit

Permalink
Don't use bytes for headers, it breaks in python3
Browse files Browse the repository at this point in the history
  • Loading branch information
ralsina committed Jul 1, 2015
1 parent 685239d commit 62609d7
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions nikola/plugins/command/auto/__init__.py
Expand Up @@ -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):
Expand Down

0 comments on commit 62609d7

Please sign in to comment.