{"id":26819,"date":"2022-12-05T09:36:51","date_gmt":"2022-12-05T01:36:51","guid":{"rendered":"http:\/\/lrxjmw.cn\/?p=26819"},"modified":"2022-12-05T09:37:39","modified_gmt":"2022-12-05T01:37:39","slug":"make-web-sever2","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/make-web-sever2.html","title":{"rendered":"Web\u670d\u52a1\u7cbe\u8bb2–\u642d\u4e2a Web \u670d\u52a1\u5668\uff08\u4e8c\uff09"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u66fe\u51e0\u4f55\u65f6\uff0c\u4f60\u6240\u9009\u62e9\u7684 Python Web \u6846\u67b6\u4f1a\u9650\u5236\u4f60\u6240\u53ef\u9009\u62e9\u7684 Web \u670d\u52a1\u5668\uff0c\u53cd\u4e4b\u4ea6\u7136\u3002\u5982\u679c\u67d0\u4e2a\u6846\u67b6\u53ca\u670d\u52a1\u5668\u8bbe\u8ba1\u7528\u6765\u534f\u540c\u5de5\u4f5c\u7684\uff0c\u90a3\u4e48\u4e00\u5207\u6b63\u5e38\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u5728\u7b2c\u4e00\u90e8\u5206\u4e2d\uff0c\u6211\u63d0\u51fa\u4e86\u4e00\u4e2a\u95ee\u9898\uff1a\u201c\u5982\u4f55\u5728\u4f60\u521a\u521a\u642d\u5efa\u8d77\u6765\u7684 Web \u670d\u52a1\u5668\u4e0a\u9002\u914d Django, Flask \u6216 Pyramid \u5e94\u7528\uff0c\u800c\u4e0d\u7528\u5355\u72ec\u5bf9 Web \u670d\u52a1\u5668\u505a\u505a\u51fa\u6539\u52a8\u4ee5\u9002\u5e94\u5404\u79cd\u4e0d\u540c\u7684 Web \u6846\u67b6\u5462\uff1f\u201d\u6211\u4eec\u53ef\u4ee5\u4ece\u8fd9\u4e00\u7bc7\u4e2d\u627e\u5230\u7b54\u6848\u3002<\/p>\n

\"\u642d\u4e2a<\/p>\n

\u4f46\u4f60\u53ef\u80fd\u6b63\u9762\u5bf9\u7740\uff08\u6216\u8005\u66fe\u7ecf\u9762\u5bf9\u8fc7\uff09\u5c1d\u8bd5\u5c06\u4e00\u5bf9\u65e0\u6cd5\u9002\u914d\u7684\u6846\u67b6\u548c\u670d\u52a1\u5668\u642d\u914d\u5728\u4e00\u8d77\u7684\u95ee\u9898\uff1a<\/p>\n

\"\u642d\u4e2a<\/p>\n

\u57fa\u672c\u4e0a\uff0c\u4f60\u9700\u8981\u9009\u62e9\u90a3\u4e9b\u80fd\u591f\u4e00\u8d77\u5de5\u4f5c\u7684\u6846\u67b6\u548c\u670d\u52a1\u5668\uff0c\u800c\u4e0d\u80fd\u9009\u62e9\u4f60\u60f3\u7528\u7684\u90a3\u4e9b\u3002<\/p>\n

\u6240\u4ee5\uff0c\u4f60\u8be5\u5982\u4f55\u786e\u4fdd\u5728\u4e0d\u5bf9 Web \u670d\u52a1\u5668\u6216\u6846\u67b6\u7684\u4ee3\u7801\u505a\u4efb\u4f55\u66f4\u6539\u7684\u60c5\u51b5\u4e0b\uff0c\u8ba9\u4f60\u7684 Web \u670d\u52a1\u5668\u548c\u591a\u4e2a\u4e0d\u540c\u7684 Web \u6846\u67b6\u4e00\u540c\u5de5\u4f5c\u5462\uff1f\u8fd9\u4e2a\u95ee\u9898\u7684\u7b54\u6848\uff0c\u5c31\u662f Python Web \u670d\u52a1\u5668\u7f51\u5173\u63a5\u53e3\uff08<\/rp>Web Server Gateway Interface <\/rt>\uff09<\/rp><\/ruby>\uff08\u7f29\u5199\u4e3a WSGI\uff0c\u5ff5\u505a\u201cwizgy\u201d\uff09\u3002<\/p>\n

\"\u642d\u4e2a<\/p>\n

WSGI \u5141\u8bb8\u5f00\u53d1\u8005\u4e92\u4e0d\u5e72\u6270\u5730\u9009\u62e9 Web \u6846\u67b6\u53ca Web \u670d\u52a1\u5668\u7684\u7c7b\u578b\u3002\u73b0\u5728\uff0c\u4f60\u53ef\u4ee5\u771f\u6b63\u5c06 Web \u670d\u52a1\u5668\u53ca\u6846\u67b6\u4efb\u610f\u642d\u914d\uff0c\u7136\u540e\u9009\u51fa\u4f60\u6700\u4e2d\u610f\u7684\u90a3\u5bf9\u7ec4\u5408\u3002\u6bd4\u5982\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 Django<\/strong>\uff0cFlask <\/strong>\u6216\u8005 Pyramid<\/strong>\uff0c\u4e0e Gunicorn<\/strong>\uff0cNginx\/uWSGI <\/strong>\u6216 Waitress<\/strong> \u8fdb\u884c\u7ed3\u5408\u3002\u611f\u8c22 WSGI \u540c\u65f6\u5bf9\u670d\u52a1\u5668\u4e0e\u6846\u67b6\u7684\u652f\u6301\uff0c\u6211\u4eec\u53ef\u4ee5\u771f\u6b63\u968f\u610f\u9009\u62e9\u5b83\u4eec\u7684\u642d\u914d\u4e86\u3002<\/p>\n

\"\u642d\u4e2a<\/p>\n

\u6240\u4ee5\uff0cWSGI \u5c31\u662f\u6211\u5728\u7b2c\u4e00\u90e8\u5206\u4e2d\u63d0\u51fa\uff0c\u53c8\u5728\u672c\u6587\u5f00\u5934\u91cd\u590d\u4e86\u4e00\u904d\u7684\u90a3\u4e2a\u95ee\u9898\u7684\u7b54\u6848\u3002\u4f60\u7684 Web \u670d\u52a1\u5668\u5fc5\u987b\u5b9e\u73b0 WSGI \u63a5\u53e3\u7684\u670d\u52a1\u5668\u90e8\u5206\uff0c\u800c\u73b0\u4ee3\u7684 Python Web \u6846\u67b6\u5747\u5df2\u5b9e\u73b0\u4e86 WSGI \u63a5\u53e3\u7684\u6846\u67b6\u90e8\u5206\uff0c\u8fd9\u4f7f\u5f97\u4f60\u53ef\u4ee5\u76f4\u63a5\u5728 Web \u670d\u52a1\u5668\u4e2d\u4f7f\u7528\u4efb\u610f\u6846\u67b6\uff0c\u800c\u4e0d\u9700\u8981\u66f4\u6539\u4efb\u4f55\u670d\u52a1\u5668\u4ee3\u7801\uff0c\u4ee5\u5bf9\u7279\u5b9a\u7684 Web \u6846\u67b6\u5b9e\u73b0\u517c\u5bb9\u3002<\/p>\n

\u73b0\u5728\uff0c\u4f60\u5df2\u7ecf\u77e5\u9053 Web \u670d\u52a1\u5668\u53ca Web \u6846\u67b6\u5bf9 WSGI \u7684\u652f\u6301\u4f7f\u5f97\u4f60\u53ef\u4ee5\u9009\u62e9\u6700\u5408\u9002\u7684\u4e00\u5bf9\u6765\u4f7f\u7528\uff0c\u800c\u4e14\u5b83\u4e5f\u6709\u5229\u4e8e\u670d\u52a1\u5668\u548c\u6846\u67b6\u7684\u5f00\u53d1\u8005\uff0c\u8fd9\u6837\u4ed6\u4eec\u53ea\u9700\u4e13\u6ce8\u4e8e\u5176\u64c5\u957f\u7684\u90e8\u5206\u6765\u8fdb\u884c\u5f00\u53d1\uff0c\u800c\u4e0d\u9700\u8981\u89e6\u53ca\u53e6\u4e00\u90e8\u5206\u7684\u4ee3\u7801\u3002\u5176\u5b83\u8bed\u8a00\u4e5f\u62e5\u6709\u7c7b\u4f3c\u7684\u63a5\u53e3\uff0c\u6bd4\u5982\uff1aJava \u62e5\u6709 Servlet API\uff0c\u800c Ruby \u62e5\u6709 Rack\u3002<\/p>\n

\u8fd9\u4e9b\u7406\u8bba\u90fd\u4e0d\u9519\uff0c\u4f46\u662f\u6211\u6253\u8d4c\u4f60\u5728\u8bf4\uff1a\u201cShow me the code!\u201d \u90a3\u597d\uff0c\u6211\u4eec\u6765\u770b\u770b\u4e0b\u9762\u8fd9\u4e2a\u5f88\u5c0f\u7684 WSGI \u670d\u52a1\u5668\u5b9e\u73b0\uff1a<\/p>\n

### \u4f7f\u7528 Python 2.7.9\uff0c\u5728 Linux \u53ca Mac OS X \u4e0b\u6d4b\u8bd5\u901a\u8fc7\r\nimport socket\r\nimport StringIO\r\nimport sys\r\n\r\nclass WSGIServer(object):\r\n\r\n    address_family = socket.AF_INET\r\n    socket_type = socket.SOCK_STREAM\r\n    request_queue_size = 1\r\n\r\n    def __init__(self, server_address):\r\n        ### \u521b\u5efa\u4e00\u4e2a\u76d1\u542c\u7684\u5957\u63a5\u5b57\r\n        self.listen_socket = listen_socket = socket.socket(\r\n            self.address_family,\r\n            self.socket_type\r\n        )\r\n        ### \u5141\u8bb8\u590d\u7528\u540c\u4e00\u5730\u5740\r\n        listen_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)\r\n        ### \u7ed1\u5b9a\u5730\u5740\r\n        listen_socket.bind(server_address)\r\n        ### \u6fc0\u6d3b\u5957\u63a5\u5b57\r\n        listen_socket.listen(self.request_queue_size)\r\n        ### \u83b7\u53d6\u4e3b\u673a\u7684\u540d\u79f0\u53ca\u7aef\u53e3\r\n        host, port = self.listen_socket.getsockname()[:2]\r\n        self.server_name = socket.getfqdn(host)\r\n        self.server_port = port\r\n        ### \u8fd4\u56de\u7531 Web \u6846\u67b6\/\u5e94\u7528\u8bbe\u5b9a\u7684\u54cd\u5e94\u5934\u90e8\u5b57\u6bb5\r\n        self.headers_set = []\r\n\r\n    def set_app(self, application):\r\n        self.application = application\r\n\r\n    def serve_forever(self):\r\n        listen_socket = self.listen_socket\r\n        while True:\r\n            ### \u83b7\u53d6\u65b0\u7684\u5ba2\u6237\u7aef\u8fde\u63a5\r\n            self.client_connection, client_address = listen_socket.accept()\r\n            ### \u5904\u7406\u4e00\u6761\u8bf7\u6c42\u540e\u5173\u95ed\u8fde\u63a5\uff0c\u7136\u540e\u5faa\u73af\u7b49\u5f85\u53e6\u4e00\u4e2a\u8fde\u63a5\u5efa\u7acb\r\n            self.handle_one_request()\r\n\r\n    def handle_one_request(self):\r\n        self.request_data = request_data = self.client_connection.recv(1024)\r\n        ### \u4ee5 'curl -v' \u7684\u98ce\u683c\u8f93\u51fa\u683c\u5f0f\u5316\u8bf7\u6c42\u6570\u636e\r\n        print(''.join(\r\n            '< {line}\/n'.format(line=line)\r\n            for line in request_data.splitlines()\r\n        ))\r\n\r\n        self.parse_request(request_data)\r\n\r\n        ### \u6839\u636e\u8bf7\u6c42\u6570\u636e\u6784\u5efa\u73af\u5883\u53d8\u91cf\u5b57\u5178\r\n        env = self.get_environ()\r\n\r\n        ### \u6b64\u65f6\u9700\u8981\u8c03\u7528 Web \u5e94\u7528\u6765\u83b7\u53d6\u7ed3\u679c\uff0c\r\n        ### \u53d6\u56de\u7684\u7ed3\u679c\u5c06\u6210\u4e3a HTTP \u54cd\u5e94\u4f53\r\n        result = self.application(env, self.start_response)\r\n\r\n        ### \u6784\u9020\u4e00\u4e2a\u54cd\u5e94\uff0c\u56de\u9001\u81f3\u5ba2\u6237\u7aef\r\n        self.finish_response(result)\r\n\r\n    def parse_request(self, text):\r\n        request_line = text.splitlines()[0]\r\n        request_line = request_line.rstrip('\/r\/n')\r\n        ### \u5c06\u8bf7\u6c42\u884c\u5206\u6210\u51e0\u4e2a\u90e8\u5206\r\n        (self.request_method,  # GET\r\n         self.path,            # \/hello\r\n         self.request_version  # HTTP\/1.1\r\n         ) = request_line.split()\r\n\r\n    def get_environ(self):\r\n        env = {}\r\n        ### \u4ee5\u4e0b\u4ee3\u7801\u6bb5\u6ca1\u6709\u9075\u5faa PEP8 \u89c4\u5219\uff0c\u4f46\u8fd9\u6837\u6392\u7248\uff0c\u662f\u4e3a\u4e86\u901a\u8fc7\u5f3a\u8c03\r\n        ### \u6240\u9700\u53d8\u91cf\u53ca\u5b83\u4eec\u7684\u503c\uff0c\u6765\u8fbe\u5230\u5176\u5c55\u793a\u76ee\u7684\u3002\r\n        ###\r\n        ### WSGI \u5fc5\u9700\u53d8\u91cf\r\n        env['wsgi.version']      = (1, 0)\r\n        env['wsgi.url_scheme']   = 'http'\r\n        env['wsgi.input']        = StringIO.StringIO(self.request_data)\r\n        env['wsgi.errors']       = sys.stderr\r\n        env['wsgi.multithread']  = False\r\n        env['wsgi.multiprocess'] = False\r\n        env['wsgi.run_once']     = False\r\n        ### CGI \u5fc5\u9700\u53d8\u91cf\r\n        env['REQUEST_METHOD']    = self.request_method    # GET\r\n        env['PATH_INFO']         = self.path              # \/hello\r\n        env['SERVER_NAME']       = self.server_name       # localhost\r\n        env['SERVER_PORT']       = str(self.server_port)  # 8888\r\n        return env\r\n\r\n    def start_response(self, status, response_headers, exc_info=None):\r\n        ### \u6dfb\u52a0\u5fc5\u8981\u7684\u670d\u52a1\u5668\u5934\u90e8\u5b57\u6bb5\r\n        server_headers = [\r\n            ('Date', 'Tue, 31 Mar 2015 12:54:48 GMT'),\r\n            ('Server', 'WSGIServer 0.2'),\r\n        ]\r\n        self.headers_set = [status, response_headers + server_headers]\r\n        ### \u4e3a\u4e86\u9075\u5faa WSGI \u534f\u8bae\uff0cstart_response \u51fd\u6570\u5fc5\u987b\u8fd4\u56de\u4e00\u4e2a 'write'\r\n        ### \u53ef\u8c03\u7528\u5bf9\u8c61\uff08\u8fd4\u56de\u503c.write \u53ef\u4ee5\u4f5c\u4e3a\u51fd\u6570\u8c03\u7528\uff09\u3002\u4e3a\u4e86\u7b80\u4fbf\uff0c\u6211\u4eec\r\n        ### \u5728\u8fd9\u91cc\u65e0\u89c6\u8fd9\u4e2a\u7ec6\u8282\u3002\r\n        ### return self.finish_response\r\n\r\n    def finish_response(self, result):\r\n        try:\r\n            status, response_headers = self.headers_set\r\n            response = 'HTTP\/1.1 {status}\/r\/n'.format(status=status)\r\n            for header in response_headers:\r\n                response += '{0}: {1}\/r\/n'.format(*header)\r\n            response += '\/r\/n'\r\n            for data in result:\r\n                response += data\r\n            ### \u4ee5 'curl -v' \u7684\u98ce\u683c\u8f93\u51fa\u683c\u5f0f\u5316\u8bf7\u6c42\u6570\u636e\r\n            print(''.join(\r\n                '> {line}\/n'.format(line=line)\r\n                for line in response.splitlines()\r\n            ))\r\n            self.client_connection.sendall(response)\r\n        finally:\r\n            self.client_connection.close()\r\n\r\nSERVER_ADDRESS = (HOST, PORT) = '', 8888\r\n\r\ndef make_server(server_address, application):\r\n    server = WSGIServer(server_address)\r\n    server.set_app(application)\r\n    return server\r\n\r\nif __name__ == '__main__':\r\n    if len(sys.argv) < 2:\r\n        sys.exit('Provide a WSGI application object as module:callable')\r\n    app_path = sys.argv[1]\r\n    module, application = app_path.split(':')\r\n    module = __import__(module)\r\n    application = getattr(module, application)\r\n    httpd = make_server(SERVER_ADDRESS, application)\r\n    print('WSGIServer: Serving HTTP on port {port} ...\/n'.format(port=PORT))\r\n    httpd.serve_forever()\r\n<\/pre>\n

\u5f53\u7136\uff0c\u8fd9\u6bb5\u4ee3\u7801\u8981\u6bd4\u7b2c\u4e00\u90e8\u5206\u7684\u670d\u52a1\u5668\u4ee3\u7801\u957f\u4e0d\u5c11\uff0c\u4f46\u5b83\u4ecd\u7136\u5f88\u77ed\uff08\u53ea\u6709\u4e0d\u5230 150 \u884c\uff09\uff0c\u4f60\u53ef\u4ee5\u8f7b\u677e\u7406\u89e3\u5b83\uff0c\u800c\u4e0d\u9700\u8981\u6df1\u7a76\u7ec6\u8282\u3002\u4e0a\u9762\u7684\u670d\u52a1\u5668\u4ee3\u7801\u8fd8\u53ef\u4ee5\u505a\u66f4\u591a\u2014\u2014\u5b83\u53ef\u4ee5\u7528\u6765\u8fd0\u884c\u4e00\u4e9b\u4f60\u559c\u6b22\u7684\u6846\u67b6\u5199\u51fa\u7684 Web \u5e94\u7528\uff0c\u53ef\u4ee5\u662f Pyramid\uff0cFlask\uff0cDjango \u6216\u5176\u5b83 Python WSGI \u6846\u67b6\u3002<\/p>\n

\u4e0d\u76f8\u4fe1\u5417\uff1f\u81ea\u5df1\u6765\u8bd5\u8bd5\u770b\u5427\u3002\u628a\u4ee5\u4e0a\u7684\u4ee3\u7801\u4fdd\u5b58\u4e3a<\/p>\n

webserver2.py<\/pre>\n

\uff0c\u6216\u76f4\u63a5\u4ece Github \u4e0a\u4e0b\u8f7d\u5b83\u3002\u5982\u679c\u4f60\u6253\u7b97\u4e0d\u52a0\u4efb\u4f55\u53c2\u6570\u800c\u76f4\u63a5\u8fd0\u884c\u5b83\uff0c\u5b83\u4f1a\u62b1\u6028\u4e00\u53e5\uff0c\u7136\u540e\u9000\u51fa\u3002<\/p>\n

$ python webserver2.py\r\nProvide a WSGI application object as module:callable\r\n<\/pre>\n

\u5b83\u60f3\u505a\u7684\u5176\u5b9e\u662f\u4e3a\u4f60\u7684 Web \u5e94\u7528\u670d\u52a1\uff0c\u800c\u8fd9\u624d\u662f\u91cd\u5934\u620f\u3002\u4e3a\u4e86\u8fd0\u884c\u8fd9\u4e2a\u670d\u52a1\u5668\uff0c\u4f60\u552f\u4e00\u9700\u8981\u7684\u5c31\u662f\u5b89\u88c5\u597d Python\u3002\u4e0d\u8fc7\uff0c\u5982\u679c\u4f60\u5e0c\u671b\u8fd0\u884c Pyramid\uff0cFlask \u6216 Django \u5e94\u7528\uff0c\u4f60\u8fd8\u9700\u8981\u5148\u5b89\u88c5\u90a3\u4e9b\u6846\u67b6\u3002\u90a3\u6211\u4eec\u628a\u8fd9\u4e09\u4e2a\u90fd\u88c5\u4e0a\u5427\u3002\u6211\u63a8\u8350\u7684\u5b89\u88c5\u65b9\u5f0f\u662f\u901a\u8fc7 virtualenv<\/strong>\u5b89\u88c5\u3002\u6309\u7167\u4ee5\u4e0b\u51e0\u6b65\u6765\u505a\uff0c\u4f60\u5c31\u53ef\u4ee5\u521b\u5efa\u5e76\u6fc0\u6d3b\u4e00\u4e2a\u865a\u62df\u73af\u5883\uff0c\u5e76\u5728\u5176\u4e2d\u5b89\u88c5\u4ee5\u4e0a\u4e09\u4e2a Web \u6846\u67b6\u3002<\/p>\n

$ [sudo] pip install virtualenv\r\n$ mkdir ~\/envs\r\n$ virtualenv ~\/envs\/lsbaws\/\r\n$ cd ~\/envs\/lsbaws\/\r\n$ ls\r\nbin  include  lib\r\n$ source bin\/activate\r\n(lsbaws) $ pip install pyramid\r\n(lsbaws) $ pip install flask\r\n(lsbaws) $ pip install django\r\n<\/pre>\n

\u73b0\u5728\uff0c\u4f60\u9700\u8981\u521b\u5efa\u4e00\u4e2a Web \u5e94\u7528\u3002\u6211\u4eec\u5148\u4ece Pyramid \u5f00\u59cb\u5427\u3002\u628a\u4ee5\u4e0b\u4ee3\u7801\u4fdd\u5b58\u4e3a<\/p>\n

pyramidapp.py<\/pre>\n

\uff0c\u5e76\u4e0e\u521a\u521a\u7684<\/p>\n

webserver2.py<\/pre>\n

\u653e\u7f6e\u5728\u540c\u4e00\u76ee\u5f55\uff0c\u6216\u76f4\u63a5\u4ece Github \u4e0b\u8f7d\u8be5\u6587\u4ef6\uff1a<\/p>\n

from pyramid.config import Configurator\r\nfrom pyramid.response import Response\r\n\r\ndef hello_world(request):\r\n    return Response(\r\n        'Hello world from Pyramid!\/n',\r\n        content_type='text\/plain',\r\n    )\r\n\r\nconfig = Configurator()\r\nconfig.add_route('hello', '\/hello')\r\nconfig.add_view(hello_world, route_name='hello')\r\napp = config.make_wsgi_app()\r\n<\/pre>\n

\u73b0\u5728\uff0c\u4f60\u53ef\u4ee5\u7528\u4f60\u81ea\u5df1\u7684 Web \u670d\u52a1\u5668\u6765\u8fd0\u884c\u4f60\u7684 Pyramid \u5e94\u7528\u4e86\uff1a<\/p>\n

(lsbaws) $ python webserver2.py pyramidapp:app\r\nWSGIServer: Serving HTTP on port 8888 ...\r\n<\/pre>\n

\u4f60\u521a\u521a\u8ba9\u4f60\u7684\u670d\u52a1\u5668\u53bb\u52a0\u8f7d Python \u6a21\u5757pyramidapp<\/strong> \u4e2d\u7684\u53ef\u6267\u884c\u5bf9\u8c61 app<\/strong>\u3002\u73b0\u5728\u4f60\u7684\u670d\u52a1\u5668\u53ef\u4ee5\u63a5\u6536\u8bf7\u6c42\uff0c\u5e76\u5c06\u5b83\u4eec\u8f6c\u53d1\u5230\u4f60\u7684 Pyramid<\/strong> \u5e94\u7528\u4e2d\u4e86\u3002\u5728\u6d4f\u89c8\u5668\u4e2d\u8f93\u5165 http:\/\/localhost:8888\/hello \uff0c\u6572\u4e00\u4e0b\u56de\u8f66\uff0c\u7136\u540e\u770b\u770b\u7ed3\u679c\uff1a<\/p>\n

\"\u642d\u4e2a<\/p>\n

\u4f60\u4e5f\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4\u884c\u5de5\u5177 curl<\/strong> \u6765\u6d4b\u8bd5\u670d\u52a1\u5668\uff1a<\/p>\n

$ curl -v http:\/\/localhost:8888\/hello\r\n...\r\n<\/pre>\n

\u770b\u770b\u670d\u52a1\u5668\u548ccurl <\/strong>\u5411\u6807\u51c6\u8f93\u51fa\u6d41\u6253\u5370\u7684\u5185\u5bb9\u5427\u3002<\/p>\n

\u73b0\u5728\u6765\u8bd5\u8bd5 Flask<\/strong>\u3002\u8fd0\u884c\u6b65\u9aa4\u8ddf\u4e0a\u9762\u7684\u4e00\u6837\u3002<\/p>\n

from flask import Flask\r\nfrom flask import Response\r\nflask_app = Flask('flaskapp')\r\n\r\n@flask_app.route('\/hello')\r\ndef hello_world():\r\n    return Response(\r\n        'Hello world from Flask!\/n',\r\n        mimetype='text\/plain'\r\n    )\r\n\r\napp = flask_app.wsgi_app\r\n<\/pre>\n

\u5c06\u4ee5\u4e0a\u4ee3\u7801\u4fdd\u5b58\u4e3a<\/p>\n

flaskapp.py<\/pre>\n

\uff0c\u6216\u8005\u76f4\u63a5\u4ece Github \u4e0b\u8f7d\uff0c\u7136\u540e\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u8fd0\u884c\u670d\u52a1\u5668\uff1a<\/p>\n

(lsbaws) $ python webserver2.py flaskapp:app\r\nWSGIServer: Serving HTTP on port 8888 ...\r\n<\/pre>\n

\u73b0\u5728\u5728\u6d4f\u89c8\u5668\u4e2d\u8f93\u5165 http:\/\/localhost:8888\/hello \uff0c\u6572\u4e00\u4e0b\u56de\u8f66\uff1a<\/p>\n

\"\u642d\u4e2a<\/p>\n

\u540c\u6837\uff0c\u5c1d\u8bd5\u4e00\u4e0b curl<\/strong>\uff0c\u7136\u540e\u4f60\u4f1a\u770b\u5230\u670d\u52a1\u5668\u8fd4\u56de\u4e86\u4e00\u6761 Flask<\/strong> \u5e94\u7528\u751f\u6210\u7684\u4fe1\u606f\uff1a<\/p>\n

$ curl -v http:\/\/localhost:8888\/hello\r\n...\r\n<\/pre>\n

\u8fd9\u4e2a\u670d\u52a1\u5668\u80fd\u5904\u7406 Django \u5e94\u7528\u5417\uff1f\u8bd5\u8bd5\u770b\u5427\uff01\u4e0d\u8fc7\u8fd9\u4e2a\u4efb\u52a1\u53ef\u80fd\u6709\u70b9\u590d\u6742\uff0c\u6240\u4ee5\u6211\u5efa\u8bae\u4f60\u5c06\u6574\u4e2a\u4ed3\u5e93\u514b\u9686\u4e0b\u6765\uff0c\u7136\u540e\u4f7f\u7528 Github \u4ed3\u5e93\u4e2d\u7684 djangoapp.py \u6765\u5b8c\u6210\u8fd9\u4e2a\u5b9e\u9a8c\u3002\u8fd9\u91cc\u7684\u6e90\u4ee3\u7801\u4e3b\u8981\u662f\u5c06 Django \u7684 helloworld \u5de5\u7a0b\uff08\u5df2\u4f7f\u7528 Django\u7684<\/p>\n

django-admin.py startproject<\/pre>\n

\u547d\u4ee4\u521b\u5efa\u5b8c\u6bd5\uff09\u6dfb\u52a0\u5230\u4e86\u5f53\u524d\u7684 Python \u8def\u5f84\u4e2d\uff0c\u7136\u540e\u5bfc\u5165\u4e86\u8fd9\u4e2a\u5de5\u7a0b\u7684 WSGI \u5e94\u7528\u3002\uff08LCTT \u8bd1\u6ce8\uff1a\u9664\u4e86\u8fd9\u91cc\u5c55\u793a\u7684\u4ee3\u7801\uff0c\u8fd8\u9700\u8981\u4e00\u4e2a\u914d\u5408\u7684 helloworld \u5de5\u7a0b\u624d\u80fd\u5de5\u4f5c\uff0c\u4ee3\u7801\u53ef\u4ee5\u53c2\u89c1 Github \u4ed3\u5e93\u3002\uff09<\/p>\n

import sys\r\nsys.path.insert(0, '.\/helloworld')\r\nfrom helloworld import wsgi\r\n\r\napp = wsgi.application\r\n<\/pre>\n

\u5c06\u4ee5\u4e0a\u4ee3\u7801\u4fdd\u5b58\u4e3a<\/p>\n

djangoapp.py<\/pre>\n

\uff0c\u7136\u540e\u7528\u4f60\u7684 Web \u670d\u52a1\u5668\u8fd0\u884c\u8fd9\u4e2a Django \u5e94\u7528\uff1a<\/p>\n

(lsbaws) $ python webserver2.py djangoapp:app\r\nWSGIServer: Serving HTTP on port 8888 ...\r\n<\/pre>\n

\u8f93\u5165\u4ee5\u4e0b\u94fe\u63a5\uff0c\u6572\u56de\u8f66\uff1a<\/p>\n

\"\u642d\u4e2a<\/p>\n

\u4f60\u8fd9\u6b21\u4e5f\u53ef\u4ee5\u5728\u547d\u4ee4\u884c\u4e2d\u6d4b\u8bd5\u2014\u2014\u4f60\u4e4b\u524d\u5e94\u8be5\u5df2\u7ecf\u505a\u8fc7\u4e24\u6b21\u4e86\u2014\u2014\u6765\u786e\u8ba4 Django \u5e94\u7528\u5904\u7406\u4e86\u4f60\u7684\u8bf7\u6c42\uff1a<\/p>\n

$ curl -v http:\/\/localhost:8888\/hello\r\n...\r\n<\/pre>\n

\u4f60\u8bd5\u8fc7\u4e86\u5417\uff1f\u4f60\u786e\u5b9a\u8fd9\u4e2a\u670d\u52a1\u5668\u53ef\u4ee5\u4e0e\u90a3\u4e09\u4e2a\u6846\u67b6\u642d\u914d\u5de5\u4f5c\u5417\uff1f\u5982\u679c\u6ca1\u8bd5\uff0c\u8bf7\u53bb\u8bd5\u4e00\u4e0b\u3002\u9605\u8bfb\u56fa\u7136\u91cd\u8981\uff0c\u4f46\u8fd9\u4e2a\u7cfb\u5217\u7684\u5185\u5bb9\u662f\u91cd\u65b0\u642d\u5efa<\/strong>\uff0c\u8fd9\u610f\u5473\u7740\u4f60\u9700\u8981\u4eb2\u81ea\u52a8\u624b\u5e72\u70b9\u6d3b\u3002\u53bb\u8bd5\u4e00\u4e0b\u5427\u3002\u522b\u62c5\u5fc3\uff0c\u6211\u7b49\u7740\u4f60\u5462\u3002\u4e0d\u5f00\u73a9\u7b11\uff0c\u4f60\u771f\u7684\u9700\u8981\u8bd5\u4e00\u4e0b\uff0c\u4eb2\u81ea\u5c1d\u8bd5\u6bcf\u4e00\u6b65\uff0c\u5e76\u786e\u4fdd\u5b83\u50cf\u9884\u671f\u7684\u90a3\u6837\u5de5\u4f5c\u3002<\/p>\n

\u597d\uff0c\u4f60\u5df2\u7ecf\u4f53\u9a8c\u5230\u4e86 WSGI \u7684\u5a01\u529b\uff1a\u5b83\u53ef\u4ee5\u4f7f Web \u670d\u52a1\u5668\u53ca Web \u6846\u67b6\u968f\u610f\u642d\u914d\u3002WSGI \u5728 Python Web \u670d\u52a1\u5668\u53ca\u6846\u67b6\u4e4b\u95f4\u63d0\u4f9b\u4e86\u4e00\u4e2a\u5fae\u578b\u63a5\u53e3\u3002\u5b83\u975e\u5e38\u7b80\u5355\uff0c\u800c\u4e14\u5728\u670d\u52a1\u5668\u548c\u6846\u67b6\u7aef\u5747\u53ef\u4ee5\u8f7b\u6613\u5b9e\u73b0\u3002\u4e0b\u9762\u7684\u4ee3\u7801\u7247\u6bb5\u5c55\u793a\u4e86 WSGI \u63a5\u53e3\u7684\u670d\u52a1\u5668\u53ca\u6846\u67b6\u7aef\u5b9e\u73b0\uff1a<\/p>\n

def run_application(application):\r\n    \"\"\"\u670d\u52a1\u5668\u7aef\u4ee3\u7801\u3002\"\"\"\r\n    ### Web \u5e94\u7528\/\u6846\u67b6\u5728\u8fd9\u91cc\u5b58\u50a8 HTTP \u72b6\u6001\u7801\u4ee5\u53ca HTTP \u54cd\u5e94\u5934\u90e8\uff0c\r\n    ### \u670d\u52a1\u5668\u4f1a\u5c06\u8fd9\u4e9b\u4fe1\u606f\u4f20\u9012\u7ed9\u5ba2\u6237\u7aef\r\n    headers_set = []\r\n    ### \u7528\u4e8e\u5b58\u50a8 WSGI\/CGI \u73af\u5883\u53d8\u91cf\u7684\u5b57\u5178\r\n    environ = {}\r\n\r\n    def start_response(status, response_headers, exc_info=None):\r\n        headers_set[:] = [status, response_headers]\r\n\r\n    ### \u670d\u52a1\u5668\u5524\u9192\u53ef\u6267\u884c\u53d8\u91cf\u201capplication\u201d\uff0c\u83b7\u5f97\u54cd\u5e94\u5934\u90e8\r\n    result = application(environ, start_response)\r\n    ### \u670d\u52a1\u5668\u7ec4\u88c5\u4e00\u4e2a HTTP \u54cd\u5e94\uff0c\u5c06\u5176\u4f20\u9001\u81f3\u5ba2\u6237\u7aef\r\n    \u2026\r\n\r\ndef app(environ, start_response):\r\n    \"\"\"\u4e00\u4e2a\u7a7a\u7684 WSGI \u5e94\u7528\"\"\"\r\n    start_response('200 OK', [('Content-Type', 'text\/plain')])\r\n    return ['Hello world!']\r\n\r\nrun_application(app)\r\n<\/pre>\n

\u8fd9\u662f\u5b83\u7684\u5de5\u4f5c\u539f\u7406\uff1a<\/p>\n

    \n
  1. Web \u6846\u67b6\u63d0\u4f9b\u4e00\u4e2a\u53ef\u8c03\u7528\u5bf9\u8c61 application <\/strong>\uff08WSGI \u89c4\u8303\u6ca1\u6709\u89c4\u5b9a\u5b83\u7684\u5b9e\u73b0\u65b9\u5f0f\uff09\u3002<\/li>\n
  2. Web \u670d\u52a1\u5668\u6bcf\u6b21\u6536\u5230\u6765\u81ea\u5ba2\u6237\u7aef\u7684 HTTP \u8bf7\u6c42\u540e\uff0c\u4f1a\u5524\u9192\u53ef\u8c03\u7528\u5bf9\u8c61 applition<\/strong>\u3002\u5b83\u4f1a\u5411\u8be5\u5bf9\u8c61\u4f20\u9012\u4e00\u4e2a\u5305\u542b WSGI\/CGI \u53d8\u91cf\u7684\u73af\u5883\u53d8\u91cf\u5b57\u5178 environ<\/strong>\uff0c\u4ee5\u53ca\u4e00\u4e2a\u53ef\u8c03\u7528\u5bf9\u8c61 start_response<\/strong>\u3002<\/li>\n
  3. Web \u6846\u67b6\u6216\u5e94\u7528\u751f\u6210 HTTP \u72b6\u6001\u7801\u548c HTTP \u54cd\u5e94\u5934\u90e8\uff0c\u7136\u540e\u5c06\u5b83\u4f20\u7ed9 start_response<\/strong> \u51fd\u6570\uff0c\u670d\u52a1\u5668\u4f1a\u5c06\u5176\u5b58\u50a8\u8d77\u6765\u3002\u540c\u65f6\uff0cWeb \u6846\u67b6\u6216\u5e94\u7528\u4e5f\u4f1a\u8fd4\u56de HTTP \u54cd\u5e94\u6b63\u6587\u3002<\/li>\n
  4. \u670d\u52a1\u5668\u5c06\u72b6\u6001\u7801\u3001\u54cd\u5e94\u5934\u90e8\u53ca\u54cd\u5e94\u6b63\u6587\u7ec4\u88c5\u6210\u4e00\u4e2a HTTP \u54cd\u5e94\uff0c\u7136\u540e\u5c06\u5176\u4f20\u9001\u81f3\u5ba2\u6237\u7aef\uff08\u8fd9\u4e00\u6b65\u5e76\u4e0d\u5728 WSGI \u89c4\u8303\u4e2d\uff0c\u4f46\u4ece\u903b\u8f91\u4e0a\u8bb2\uff0c\u8fd9\u4e00\u6b65\u5e94\u8be5\u5305\u542b\u5728\u5de5\u4f5c\u6d41\u7a0b\u4e4b\u4e2d\u3002\u6240\u4ee5\u4e3a\u4e86\u660e\u786e\u8fd9\u4e2a\u8fc7\u7a0b\uff0c\u6211\u628a\u5b83\u5199\u4e86\u51fa\u6765\uff09<\/li>\n<\/ol>\n

    \u8fd9\u662f\u8fd9\u4e2a\u63a5\u53e3\u89c4\u8303\u7684\u56fe\u5f62\u5316\u8868\u8fbe\uff1a<\/p>\n

    \"\u642d\u4e2a<\/p>\n

    \u5230\u73b0\u5728\u4e3a\u6b62\uff0c\u4f60\u5df2\u7ecf\u770b\u8fc7\u4e86\u7528 Pyramid\u3001Flask \u548c Django \u5199\u51fa\u7684 Web \u5e94\u7528\u7684\u4ee3\u7801\uff0c\u4f60\u4e5f\u770b\u5230\u4e86\u4e00\u4e2a Web \u670d\u52a1\u5668\u5982\u4f55\u7528\u4ee3\u7801\u6765\u5b9e\u73b0\u53e6\u4e00\u534a\uff08\u670d\u52a1\u5668\u7aef\u7684\uff09 WSGI \u89c4\u8303\u3002\u4f60\u751a\u81f3\u8fd8\u770b\u5230\u4e86\u6211\u4eec\u5982\u4f55\u5728\u4e0d\u4f7f\u7528\u4efb\u4f55\u6846\u67b6\u7684\u60c5\u51b5\u4e0b\uff0c\u4f7f\u7528\u4e00\u6bb5\u4ee3\u7801\u6765\u5b9e\u73b0\u4e00\u4e2a\u6700\u7b80\u5355\u7684 WSGI Web \u5e94\u7528\u3002<\/p>\n

    \u5176\u5b9e\uff0c\u5f53\u4f60\u4f7f\u7528\u4e0a\u9762\u7684\u6846\u67b6\u7f16\u5199\u4e00\u4e2a Web \u5e94\u7528\u65f6\uff0c\u4f60\u53ea\u662f\u5728\u8f83\u9ad8\u7684\u5c42\u9762\u5de5\u4f5c\uff0c\u800c\u4e0d\u9700\u8981\u76f4\u63a5\u4e0e WSGI \u6253\u4ea4\u9053\u3002\u4f46\u662f\u6211\u77e5\u9053\u4f60\u4e00\u5b9a\u4e5f\u5bf9 WSGI \u63a5\u53e3\u7684\u6846\u67b6\u90e8\u5206\u611f\u5174\u8da3\uff0c\u56e0\u4e3a\u4f60\u5728\u770b\u8fd9\u7bc7\u6587\u7ae0\u5440\u3002\u6240\u4ee5\uff0c\u6211\u4eec\u4e0d\u7528 Pyramid\u3001Flask \u6216 Django\uff0c\u800c\u662f\u81ea\u5df1\u52a8\u624b\u6765\u521b\u9020\u4e00\u4e2a\u6700\u6734\u7d20\u7684 WSGI Web \u5e94\u7528\uff08\u6216 Web \u6846\u67b6\uff09\uff0c\u7136\u540e\u5c06\u5b83\u548c\u4f60\u7684\u670d\u52a1\u5668\u4e00\u8d77\u8fd0\u884c\uff1a<\/p>\n

    def app(environ, start_response):\r\n    \"\"\"\u4e00\u4e2a\u6700\u7b80\u5355\u7684 WSGI \u5e94\u7528\u3002\r\n\r\n    \u8fd9\u662f\u4f60\u81ea\u5df1\u7684 Web \u6846\u67b6\u7684\u8d77\u70b9 ^_^\r\n    \"\"\"\r\n    status = '200 OK'\r\n    response_headers = [('Content-Type', 'text\/plain')]\r\n    start_response(status, response_headers)\r\n    return ['Hello world from a simple WSGI application!\/n']\r\n<\/pre>\n

    \u540c\u6837\uff0c\u5c06\u4e0a\u9762\u7684\u4ee3\u7801\u4fdd\u5b58\u4e3a<\/p>\n

    wsgiapp.py<\/pre>\n

    \u6216\u76f4\u63a5\u4ece Github \u4e0a\u4e0b\u8f7d\u8be5\u6587\u4ef6\uff0c\u7136\u540e\u5728 Web \u670d\u52a1\u5668\u4e0a\u8fd0\u884c\u8fd9\u4e2a\u5e94\u7528\uff0c\u50cf\u8fd9\u6837\uff1a<\/p>\n

    (lsbaws) $ python webserver2.py wsgiapp:app\r\nWSGIServer: Serving HTTP on port 8888 ...\r\n<\/pre>\n

    \u5728\u6d4f\u89c8\u5668\u4e2d\u8f93\u5165\u4e0b\u9762\u7684\u5730\u5740\uff0c\u7136\u540e\u6309\u4e0b\u56de\u8f66\u3002\u8fd9\u662f\u4f60\u5e94\u8be5\u770b\u5230\u7684\u7ed3\u679c\uff1a<\/p>\n

    \"\u642d\u4e2a<\/p>\n

    \u4f60\u521a\u521a\u5728\u5b66\u4e60\u5982\u4f55\u521b\u5efa\u4e00\u4e2a Web \u670d\u52a1\u5668\u7684\u8fc7\u7a0b\u4e2d\u81ea\u5df1\u7f16\u5199\u4e86\u4e00\u4e2a\u6700\u6734\u7d20\u7684 WSGI Web \u6846\u67b6\uff01\u68d2\u6781\u4e86\uff01<\/p>\n

    \u73b0\u5728\uff0c\u6211\u4eec\u518d\u56de\u6765\u770b\u770b\u670d\u52a1\u5668\u4f20\u7ed9\u5ba2\u6237\u7aef\u7684\u90a3\u4e9b\u4e1c\u897f\u3002\u8fd9\u662f\u5728\u4f7f\u7528 HTTP \u5ba2\u6237\u7aef\u8c03\u7528\u4f60\u7684 Pyramid \u5e94\u7528\u65f6\uff0c\u670d\u52a1\u5668\u751f\u6210\u7684 HTTP \u54cd\u5e94\u5185\u5bb9\uff1a<\/p>\n

    \"\u642d\u4e2a<\/p>\n

    \u8fd9\u4e2a\u54cd\u5e94\u548c\u4f60\u5728\u672c\u7cfb\u5217\u7b2c\u4e00\u90e8\u5206\u4e2d\u770b\u5230\u7684 HTTP \u54cd\u5e94\u6709\u4e00\u90e8\u5206\u5171\u540c\u70b9\uff0c\u4f46\u5b83\u8fd8\u591a\u51fa\u6765\u4e86\u4e00\u4e9b\u5185\u5bb9\u3002\u6bd4\u5982\u8bf4\uff0c\u5b83\u62e5\u6709\u56db\u4e2a\u4f60\u66fe\u7ecf\u6ca1\u89c1\u8fc7\u7684 HTTP \u5934\u90e8\uff1aContent-Type<\/strong>, Content-Length<\/strong>, Date <\/strong>\u4ee5\u53caServer<\/strong>\u3002\u8fd9\u4e9b\u5934\u90e8\u5185\u5bb9\u57fa\u672c\u4e0a\u5728\u6bcf\u4e2a Web \u670d\u52a1\u5668\u8fd4\u56de\u7684\u54cd\u5e94\u4e2d\u90fd\u4f1a\u51fa\u73b0\u3002\u4e0d\u8fc7\uff0c\u5b83\u4eec\u90fd\u4e0d\u662f\u88ab\u4e25\u683c\u8981\u6c42\u51fa\u73b0\u7684\u3002\u8fd9\u4e9b HTTP \u8bf7\u6c42\/\u54cd\u5e94\u5934\u90e8\u5b57\u6bb5\u7684\u76ee\u7684\u5728\u4e8e\u5b83\u53ef\u4ee5\u5411\u4f60\u4f20\u9012\u4e00\u4e9b\u5173\u4e8e HTTP \u8bf7\u6c42\/\u54cd\u5e94\u7684\u989d\u5916\u4fe1\u606f\u3002<\/p>\n

    \u65e2\u7136\u4f60\u5bf9 WSGI \u63a5\u53e3\u4e86\u89e3\u7684\u66f4\u6df1\u4e86\u4e00\u4e9b\uff0c\u90a3\u6211\u518d\u6765\u5c55\u793a\u4e00\u4e0b\u4e0a\u9762\u90a3\u4e2a HTTP \u54cd\u5e94\u4e2d\u7684\u5404\u4e2a\u90e8\u5206\u7684\u4fe1\u606f\u6765\u6e90\uff1a<\/p>\n

    \"\u642d\u4e2a<\/p>\n

    \u6211\u73b0\u5728\u8fd8\u6ca1\u6709\u5bf9\u4e0a\u9762\u90a3\u4e2aenviron <\/strong>\u5b57\u5178\u505a\u4efb\u4f55\u89e3\u91ca\uff0c\u4e0d\u8fc7\u57fa\u672c\u4e0a\u8fd9\u4e2a\u5b57\u5178\u5fc5\u987b\u5305\u542b\u90a3\u4e9b\u88ab WSGI \u89c4\u8303\u4e8b\u5148\u5b9a\u4e49\u597d\u7684 WSGI \u53ca CGI \u53d8\u91cf\u503c\u3002\u670d\u52a1\u5668\u5728\u89e3\u6790 HTTP \u8bf7\u6c42\u65f6\uff0c\u4f1a\u4ece\u8bf7\u6c42\u4e2d\u83b7\u53d6\u8fd9\u4e9b\u53d8\u91cf\u7684\u503c\u3002\u8fd9\u662f environ<\/strong> \u5b57\u5178\u5e94\u8be5\u6709\u7684\u6837\u5b50\uff1a<\/p>\n

    \"\u642d\u4e2a<\/p>\n

    Web \u6846\u67b6\u4f1a\u5229\u7528\u4ee5\u4e0a\u5b57\u5178\u4e2d\u5305\u542b\u7684\u4fe1\u606f\uff0c\u901a\u8fc7\u5b57\u5178\u4e2d\u7684\u8bf7\u6c42\u8def\u5f84\u3001\u8bf7\u6c42\u52a8\u4f5c\u7b49\u7b49\u6765\u51b3\u5b9a\u4f7f\u7528\u54ea\u4e2a\u89c6\u56fe\u6765\u5904\u7406\u54cd\u5e94\u3001\u5728\u54ea\u91cc\u8bfb\u53d6\u8bf7\u6c42\u6b63\u6587\u3001\u5728\u54ea\u91cc\u8f93\u51fa\u9519\u8bef\u4fe1\u606f\uff08\u5982\u679c\u6709\u7684\u8bdd\uff09\u3002<\/p>\n

    \u73b0\u5728\uff0c\u4f60\u5df2\u7ecf\u521b\u9020\u4e86\u5c5e\u4e8e\u4f60\u81ea\u5df1\u7684 WSGI Web \u670d\u52a1\u5668\uff0c\u4f60\u4e5f\u4f7f\u7528\u4e0d\u540c Web \u6846\u67b6\u505a\u4e86\u51e0\u4e2a Web \u5e94\u7528\u3002\u800c\u4e14\uff0c\u4f60\u5728\u8fd9\u4e2a\u8fc7\u7a0b\u4e2d\u4e5f\u81ea\u5df1\u521b\u9020\u51fa\u4e86\u4e00\u4e2a\u6734\u7d20\u7684 Web \u5e94\u7528\u53ca\u6846\u67b6\u3002\u8fd9\u4e2a\u8fc7\u7a0b\u771f\u662f\u7d2f\u4eba\u3002\u73b0\u5728\u6211\u4eec\u6765\u56de\u987e\u4e00\u4e0b\uff0c\u4f60\u7684 WSGI Web \u670d\u52a1\u5668\u5728\u670d\u52a1\u8bf7\u6c42\u65f6\uff0c\u9700\u8981\u9488\u5bf9 WSGI \u5e94\u7528\u505a\u4e9b\u4ec0\u4e48\uff1a<\/p>\n