WSGI 实际上并不是 FastCGI 上的一层,而是一种用于编写 Python Web 应用程序的规范,它非常通用,可以附加到许多 Web 服务器或适配器,而这些服务器或适配器又可以与许多其他技术(包括FastCGI )交互。但是 FastCGI 本身是一种用于 Web 服务器连接到长时间运行的进程的协议,根本不需要参与 WSGI 安装\xe2\x80\x94e.g.。Apache模块mod_wsgi,它直接从 Apache 向您的 Python 应用程序公开 WSGI,并且不需要您运行单独的长时间运行的进程。
WSGI 在PEP 333中定义。取自该规范的一个简单应用程序如下所示:
\n\ndef simple_app(environ, start_response):\n """Simplest possible application object"""\n status = \'200 OK\'\n response_headers = [(\'Content-type\', \'text/plain\')]\n start_response(status, response_headers)\n return [\'Hello world!\\n\']\nRun Code Online (Sandbox Code Playgroud)\n