我有一个简单的webapp要构建,我刚刚开始和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()
应用程序在没有服务器的情况下运行,那么服务器的作用是什么?
目前没有回答
相关问题 更多 >
编程相关推荐