recipe-577047.py 文件源码

python
阅读 49 收藏 0 点赞 0 评论 0

项目:code 作者: ActiveState 项目源码 文件源码
def __call_service(self, query):
        """Execute service method implemented by child class.

        When either a GET or POST request is received, this method is
        called with a string representing the query. Request and response
        objects are created for the child's service method, and an answer
        is sent back to the client with errors automatically being caught."""
        request = _HttpServletRequest(query)
        response = _HttpServletResponse()
        try:
            self.service(request, response)
        except Exception:
            if self.__debug:
                self.send_response(500)
                self.send_header('Content-Type', 'text/html')
                self.send_header('Connection', 'close')
                self.end_headers()
                klass, value, trace = sys.exc_info()
                # The next function call may raise an exception.
                html = cgitb.html((klass, value, trace.tb_next))
                self.wfile.write(html.encode())
            else:
                self.send_error(500)
        else:
            response_value = response._value
            self.send_response(200)
            self.send_header('Content-Type', response._type)
            self.send_header('Content-Length', str(len(response_value)))
            self.end_headers()
            self.wfile.write(response_value)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号