【发布时间】:2011-07-13 17:49:53
【问题描述】:
我有一个简单的 web 应用程序要构建,我刚刚开始搞乱 mod_wsgi。在各种教程中,第一个 hello world 应用如下所示:
def application(environ,start_response):
response_body = 'Hello World'
status = '200 OK'
response_headers = [('Content-Type', 'text/plain'),
('Content-Length', str(len(response_body)))]
start_response(status, response_headers)
return [response_body]
然后,稍后该应用程序包含一个使用 wsgiref 的 wsgi 服务器,一些变体:
from wsgiref.simple_server import make_server
def application(environ, start_response):
response_body = 'Hello World'
status = '200 OK'
response_headers = [('Content-Type', 'text/plain'),
('Content-Length', str(len(response_body)))]
start_response(status, response_headers)
return [response_body]
httpd = make_server('localhost', 8000, application)
httpd.serve_forever()
应用程序在没有服务器的情况下工作,那么服务器是干什么用的?
【问题讨论】:
标签: python mod-wsgi wsgi wsgiref