@@ -106,21 +106,21 @@ def handle_static(environ, start_response, path):
106
106
:return: wsgi response for the static file.
107
107
"""
108
108
try :
109
- text = open (path ).read ()
109
+ data = open (path , 'rb' ).read ()
110
110
if path .endswith (".ico" ):
111
- resp = Response (text , headers = [('Content-Type' , "image/x-icon" )])
111
+ resp = Response (data , headers = [('Content-Type' , "image/x-icon" )])
112
112
elif path .endswith (".html" ):
113
- resp = Response (text , headers = [('Content-Type' , 'text/html' )])
113
+ resp = Response (data , headers = [('Content-Type' , 'text/html' )])
114
114
elif path .endswith (".txt" ):
115
- resp = Response (text , headers = [('Content-Type' , 'text/plain' )])
115
+ resp = Response (data , headers = [('Content-Type' , 'text/plain' )])
116
116
elif path .endswith (".css" ):
117
- resp = Response (text , headers = [('Content-Type' , 'text/css' )])
117
+ resp = Response (data , headers = [('Content-Type' , 'text/css' )])
118
118
elif path .endswith (".js" ):
119
- resp = Response (text , headers = [('Content-Type' , 'text/javascript' )])
119
+ resp = Response (data , headers = [('Content-Type' , 'text/javascript' )])
120
120
elif path .endswith (".png" ):
121
- resp = Response (text , headers = [('Content-Type' , 'image/png' )])
121
+ resp = Response (data , headers = [('Content-Type' , 'image/png' )])
122
122
else :
123
- resp = Response (text )
123
+ resp = Response (data )
124
124
except IOError :
125
125
resp = NotFound ()
126
126
return resp (environ , start_response )
0 commit comments