Home > front end >  Python requests transfer PDF times wrong: BrokenPipeError: [32] Errno Broken pipe
Python requests transfer PDF times wrong: BrokenPipeError: [32] Errno Broken pipe

Time:02-10

Everybody is good, I want to do a query and a PDF of the python API:
This is my main code:
 
App=Flask (__name__)

@ app. The route ('/')
Def index () :
App. The logger. The info (" identifiers a request ")
If (request) method=="POST") :
Query=request. The args. The get (" query ")
The file=request. Files [' file ']
App. The logger. The info (query)
App. Logger. The info (file. Name)
If not the file or not query:
Raise the Exception (" Missing doc or query ")

Return "success"
Return "hihi"


This is my simple test code
 
Url="http://localhost:5000? Query="How is the stock price" '


Files={' address} {file ', 'rb')}
Print (files)
R=requests. Post (url, files)

Data=https://bbs.csdn.net/topics/r.text
Print (r)


This is the flask to log:
 
* Serving Flask app "app"
* the Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production home WSGI server.
* the Debug mode: off
02/07/2021 16:21:15 - INFO - faiss - Loading faiss.
02/07/2021 16:21:19 - INFO - werkzeug - * Running on http://127.0.0.1:5000/(Press CTRL + C to quit)
02/07/2021 16:21:22 - INFO - werkzeug - 127.0.0.1-07/Feb/2021 16:21:22 "POST/? Query=% 22 how % 20 is % 20 the % 20 stock % 20 price % 22 HTTP/1.1 "405 -


This is an error
 Traceback (the most recent call last) : 
The File "/Users/chaozy/opt/anaconda3/lib/python3.8/site - packages/urllib3 connectionpool. Py", line 670, in urlopen
Httplib_response=self. _make_request (
The File "/Users/chaozy/opt/anaconda3/lib/python3.8/site - packages/urllib3 connectionpool. Py", line 392, in _make_request
Conn. Request (method, url, * * httplib_request_kw)
The File "/Users/chaozy/opt/anaconda3/lib/python3.8/HTTP/client. Py", line 1240, in the request
Self. _send_request (method, url, body, headers, encode_chunked)
The File "/Users/chaozy/opt/anaconda3/lib/python3.8/HTTP/client. Py", line 1286, in _send_request
Self. Endheaders (body, encode_chunked=encode_chunked)
The File "/Users/chaozy/opt/anaconda3/lib/python3.8/HTTP/client. Py", line 1235, in endheaders
Self. _send_output (message_body, encode_chunked=encode_chunked)
The File "/Users/chaozy/opt/anaconda3/lib/python3.8/HTTP/client. Py", line 1045, in _send_output
The self. The send (the chunk)
The File "/Users/chaozy/opt/anaconda3/lib/python3.8/HTTP/client. Py", line 967, in the send
The self. The sock. Sendall (data)
BrokenPipeError: [32] Errno Broken pipe

During handling of the above exception, another exception occurred:

Traceback (the most recent call last) :
The File "/Users/chaozy/opt/anaconda3/lib/python3.8/site - packages/requests/adapters. Py", line 439, in the send
Resp=conn. Urlopen (
The File "/Users/chaozy/opt/anaconda3/lib/python3.8/site - packages/urllib3 connectionpool. Py", line 724, in urlopen
Retries=retries. Increment (
The File "/Users/chaozy/opt/anaconda3/lib/python3.8/site - packages/urllib3/util/retry. Py", line 403, the increment in
Raise the six reraise (type (error), the error, _stacktrace)
The File "/Users/chaozy/opt/anaconda3/lib/python3.8/site - packages/urllib3/packages/six. Py", line 734, reraise in
Raise the value. With_traceback (TB)
The File "/Users/chaozy/opt/anaconda3/lib/python3.8/site - packages/urllib3 connectionpool. Py", line 670, in urlopen
Httplib_response=self. _make_request (
The File "/Users/chaozy/opt/anaconda3/lib/python3.8/site - packages/urllib3 connectionpool. Py", line 392, in _make_request
Conn. Request (method, url, * * httplib_request_kw)
The File "/Users/chaozy/opt/anaconda3/lib/python3.8/HTTP/client. Py", line 1240, in the request
Self. _send_request (method, url, body, headers, encode_chunked)
The File "/Users/chaozy/opt/anaconda3/lib/python3.8/HTTP/client. Py", line 1286, in _send_request
Self. Endheaders (body, encode_chunked=encode_chunked)
The File "/Users/chaozy/opt/anaconda3/lib/python3.8/HTTP/client. Py", line 1235, in endheaders
Self. _send_output (message_body, encode_chunked=encode_chunked)
The File "/Users/chaozy/opt/anaconda3/lib/python3.8/HTTP/client. Py", line 1045, in _send_output
The self. The send (the chunk)
The File "/Users/chaozy/opt/anaconda3/lib/python3.8/HTTP/client. Py", line 967, in the send
The self. The sock. Sendall (data)
Urllib3. Exceptions. ProtocolError: (' Connection aborted. 'BrokenPipeError (32,' Broken pipe '))

During handling of the above exception, another exception occurred:

Traceback (the most recent call last) :
The File "/Users/chaozy/Desktop/CS/UCL_Year2/COMP0016/COMP0016_2020_21_Team8/test/testQA testQAFunctions. Py", line 10, the in & lt; module>
R=requests. Post (url, files)
The File "/Users/chaozy/opt/anaconda3/lib/python3.8/site - packages/requests/API. Py", line 119, in the post
Return the request (' post 'url, data=https://bbs.csdn.net/topics/data, json=json, * * kwargs)
The File "/Users/chaozy/opt/anaconda3/lib/python3.8/site - packages/requests/API. Py", line 61, in the request
nullnullnullnullnullnullnullnullnullnull
  • Related