如果不加注意,uwsgi会小心谨慎,以免 泄漏
错误,但是如果您在更严格的实现中运行应用程序,例如python附带的实现
wsgiref.simple_server,您会更容易看到问题。
Serving <function application at 0xb65848> http://0.0.0.0:8000Traceback (most recent call last): File "/usr/lib64/python3.2/wsgiref/handlers.py", line 138, in run self.finish_response() File "/usr/lib64/python3.2/wsgiref/handlers.py", line 179, in finish_response self.write(data) File "/usr/lib64/python3.2/wsgiref/handlers.py", line 264, in write "write() argument must be a bytes instance"AssertionError: write() argument must be a bytes instancelocalhost.localdomain - - [04/Aug/2012 16:27:08] "GET / HTTP/1.1" 500 59
问题是wsgi要求必须以HTTP身份传输往返HTTP网关的数据
bytes,但是当您使用时
open(path, 'r'),python
3会
str使用默认编码方便地将读取的数据转换为unipre,在python 3中是这样。
改变
fh = open(path, 'r')
至
fh = open(path, 'rb')# ^
解决它。



