此时的apache就是wsgi服务器了。也许有人会问什么是wsgi服务器。
# -*- coding: utf-8 -*- from wsgiref import simple_server 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] # 下面两行就是简单的wsgi服务器 server = simple_server.make_server('localhost', 8080, application) server.serve_forever()注意这行:
server = simple_server.make_server('localhost', 8080, application)的参数application。这在apache里肯定无法编译进去,所以需要你在你的虚拟主机配置文件的
def application(environ, start_response): status = '200 OK' output = '<h1>Hello World!</h1>' response_headers = [('Content-type', 'text/plain'), ('Content-Length', str(len(output)))] start_response(status, response_headers) return [output]或者