Python 在werkzeug中发送http put请求

Python 在werkzeug中发送http put请求,python,httplib,werkzeug,Python,Httplib,Werkzeug,在我的web应用程序中,我使用werkzeug来监听和处理请求。在其中一个功能中,我需要监听请求(比如来自A)并将http put请求发送到另一个服务器(B),然后在从B获得响应后,我响应A响应 我不太熟悉werkzeug,也不确定它是否能够发送请求,所以我使用httplib发送请求 但是我有错误 有很多活动部件,我想知道以下几点: 1.werkzeug有能力发出请求吗 2.错误的原因是什么 谢谢你的帮助 代码: 错误: 1**.1**.1**.** - - [30/Dec/20

在我的web应用程序中,我使用werkzeug来监听和处理请求。在其中一个功能中,我需要监听请求(比如来自A)并将http put请求发送到另一个服务器(B),然后在从B获得响应后,我响应A响应

我不太熟悉werkzeug,也不确定它是否能够发送请求,所以我使用httplib发送请求

但是我有错误

有很多活动部件,我想知道以下几点: 1.werkzeug有能力发出请求吗 2.错误的原因是什么

谢谢你的帮助

代码:

错误:

        1**.1**.1**.** - - [30/Dec/2011 03:06:57] "GET //complete?location_id=615201308&status_code=LIVE&message=fine HTTP/1.1" 500 -
        Traceback (most recent call last):
        File "/home/ec2-user/y_ws.py", line 381, in __call__
        return self.wsgi_app(environ, start_response)
        File "/usr/lib/python2.6/site-packages/Werkzeug-0.8.1-py2.6.egg/werkzeug/wsgi.py", line 411, in __call__
            return self.app(environ, start_response)
          File "/home/ec2-user/y_ws.py", line 377, in wsgi_app
            response = self.dispatch_request(request);
          File "/home/ec2-user/y_ws.py", line 98, in dispatch_request
            return getattr(self, endpoint)(request, **values)
          File "/home/ec2-user/y_ws.py", line 184, in complete
           connection.request('PUT', y_req_url, body_content, headers);
          File "/usr/lib64/python2.6/httplib.py", line 914, in request
            self._send_request(method, url, body, headers)
          File "/usr/lib64/python2.6/httplib.py", line 951, in _send_request
            self.endheaders()
          File "/usr/lib64/python2.6/httplib.py", line 908, in endheaders
            self._send_output()
          File "/usr/lib64/python2.6/httplib.py", line 780, in _send_output
            self.send(msg)
          File "/usr/lib64/python2.6/httplib.py", line 739, in send
            self.connect()
          File "/usr/lib64/python2.6/httplib.py", line 720, in connect
            self.timeout)
          File "/usr/lib64/python2.6/socket.py", line 567, in create_connection
            raise error, msg
        error: [Errno 111] Connection refused
  • Werkzeug不是用于发出HTTP请求的库,请使用httplib(如您的示例所示)
  • 使用curl检查来自主机的请求是否成功,以排除网络问题。您得到的错误是一般网络错误
  •         1**.1**.1**.** - - [30/Dec/2011 03:06:57] "GET //complete?location_id=615201308&status_code=LIVE&message=fine HTTP/1.1" 500 -
            Traceback (most recent call last):
            File "/home/ec2-user/y_ws.py", line 381, in __call__
            return self.wsgi_app(environ, start_response)
            File "/usr/lib/python2.6/site-packages/Werkzeug-0.8.1-py2.6.egg/werkzeug/wsgi.py", line 411, in __call__
                return self.app(environ, start_response)
              File "/home/ec2-user/y_ws.py", line 377, in wsgi_app
                response = self.dispatch_request(request);
              File "/home/ec2-user/y_ws.py", line 98, in dispatch_request
                return getattr(self, endpoint)(request, **values)
              File "/home/ec2-user/y_ws.py", line 184, in complete
               connection.request('PUT', y_req_url, body_content, headers);
              File "/usr/lib64/python2.6/httplib.py", line 914, in request
                self._send_request(method, url, body, headers)
              File "/usr/lib64/python2.6/httplib.py", line 951, in _send_request
                self.endheaders()
              File "/usr/lib64/python2.6/httplib.py", line 908, in endheaders
                self._send_output()
              File "/usr/lib64/python2.6/httplib.py", line 780, in _send_output
                self.send(msg)
              File "/usr/lib64/python2.6/httplib.py", line 739, in send
                self.connect()
              File "/usr/lib64/python2.6/httplib.py", line 720, in connect
                self.timeout)
              File "/usr/lib64/python2.6/socket.py", line 567, in create_connection
                raise error, msg
            error: [Errno 111] Connection refused