Apache支持wsgi爬坑记录

来源:互联网 发布:君将哀而生之乎的生 编辑:程序博客网 时间:2024/06/07 21:12

学习python3中cgi编程。服务器用Apache。

运行时Apache错误日志显示

[Wed Oct 25 18:57:18 2017] [error] [client 127.0.0.1] mod_wsgi (pid=12587): Target WSGI script '/Applications/MAMP/cgi-bin/myTest-cgi.py' does not contain WSGI application 'application'.

仔细检查发现使用的是wsgi,多番查询,发现需要在py中使用如下接口方可正常使用。

def application(environ, start_response):    start_response('200 OK', [('Content-Type', 'text/plain')])    # yield "Hello world!\n"    return helloWorld()def helloWorld():    return 'hellor world'