查看原文 智慧煮粥博客
当我们编写wsgi时候报错
错误内容
self.status.split(' ',1)[0], self.bytes_sent
AttributeError: 'NoneType' object has no attribute 'split'
出错代码
def application(environ,start_response):
status = '200 OK'
response_headers = [('Content-type', 'text/plain')]
start_response(status, response_headers)
return [u"hello"]
from wsgiref.simple_server import make_server
#导入系统的wsgi包
from webapp import application
#引入服务器的代码
server =make_server('', 8080, application)
#实例化一个监听8080端口的服务器
server.serve_forever()
#开始监听http请求
解决方案
给返回内容加上.encode(‘utf8’)
return [u"hello".encode('utf8')]
可以关注博客 http://www.zzhub.cn

本文介绍了一个关于WSGI应用在运行过程中出现的错误——AttributeError:'NoneType' object has no attribute 'split',并提供了相应的解决方案,即在返回的内容中加入.encode('utf8')。
31万+

被折叠的 条评论
为什么被折叠?



