以下基于Apache 2.2,Windows和mod_wsgi 3.3的WSGI设置有什么问题? 问题在于,即使访问没有关联应用程序的URL(例如http:// wsgi / any ),客户端也会获得OK响应状态,而不是404状态码。
WSGI应用程序脚本文件:
# C:\Programmi\Apache Software Foundation\Apache2.2\wsgi\scripts\app.wsgi def application(environ, start_response): status = '200 OK' output = 'App WSGI: Hello World!' response_headers = [('Content-type', 'text/plain'), ('Content-Length', str(len(output)))] start_response(status, response_headers) return [output]
虚拟主机:
<VirtualHost *:80> ServerName wsgi WSGIScriptAlias / "C:\Programmi\Apache Software Foundation\Apache2.2\wsgi\scripts\app.wsgi" <Directory "C:\Programmi\Apache Software Foundation\Apache2.2\wsgi\scripts"> Order allow,deny Allow from all </Directory> </VirtualHost>
主机文件名称parsing:
127.0.0.1 wsgi
非常感谢。
使用:
WSGIScriptAlias / ...
表示将所有对“/”下的URL的请求发送到WSGI应用程序。 换句话说,您的网站的每个请求都将由WSGI应用程序处理。
所以,没有什么不对,因为这是你所要做的。