实际上代码:
def app(environ, start_response):
start_response('200 OK', [('Content-type', 'text/html')])
with codecs.open("template.html", 'r', 'utf8') as template_file:
template_content = template_file.read()
return template_content
和一个空的服务器响应
GET / => generated 0 bytes in 1 msecs (HTTP/1.1 200) 1 headers in 44 bytes (1105 switches on core 0)
该文档为空。如果将 template_content 替换为 u"Hi" - 同样的事情。“你好”是正常的回答。
return str(template_content) 抛出编码错误
UnicodeEncodeError: 'ascii' codec can't encode characters in position 82-86: ordinal not in range(128)
检查 uwsgi 和 wsgiref.simple_server
1 个回答