在测试uwsgi时,一般会编写如下测试文件
对于python2:
def application(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/html')])
test = 'hello world'
return test
对于python3则应当注意要指明编码,否则uwsgi不会发送网页内容。
def application(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/html')])
test = 'hello world'
return test.encode("utf-8")
#或者 return test.encode("ascii")
本文介绍在使用UWSGI进行应用测试时,Python2与Python3代码的主要区别,强调了Python3中编码设置的重要性,以确保正确的内容类型传输。
1361

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



