使uWSGI正常运行并正常运行

我刚刚开始使用wsgi,并试图让一个简单的uwsgi服务器启动并运行。 我build立了一个virtualenv环境并激活它。 在lib中我有一个文件hello.py的内容:

def application(environ, start_response): status = '200 OK' output = 'Hello World!' response_headers = [('Content-type', 'text/plain'), ('Content-Length', str(len(output)))] start_response(status, response_headers) return [output] 

我正在运行:

 uwsgi --http :8000 --wsgi-file lib/hello.py --add-header "X-test: hi" 

启动服务器。

我的问题是,服务器没有sedning身体。 当我curl到本地主机:8000我可以看到Xtesting头,所以我肯定打uwsgi。 此外,如果我将“200 OK”更改为其他内容,我也可以看到curl。

我相当肯定我正确地跟着教程(这看起来很简单),任何人都可以发现我做错了什么? 难道是我正在使用python3吗? 如果真的很重要的话,我可以在我的virtualenv中通过pip安装uwsgi。

WSGI for python3是不同的,你的输出必须是字节而不是string