You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So the errors I get which might happen to others too;
Here is my code;
url = “http://www.X.com/upload.php/” #url of the webpage which works in Spyder!
headers = {
‘User-Agent’: ‘Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:55.0) Gecko/20100101 Firefox/55.0’,
}
file = {‘file’: open(‘0.png’, ‘rb’)} #open file to post
r = urequests.post(url, files=file, headers=headers) #post request of file to url
print(r.status_code) #status code 200 means success
c = r.content #content of the response in bytes
print(c) #prints units
First error:
TypeError: function takes 2 positional arguments but 4 were given
in line 53 of the new urequest.py code:
ai = usocket.getaddrinfo(host, port, 0, usocket.SOCK_STREAM)
I removed the 0 and usocket.sock_stream so this was resolved
2nd error:
TypeError: object with buffer protocol required
some forums suggested changed it to json and it was resolved;
r = requests.post(url, json=file, headers=headers)
3rd error;
AttributeError: ‘socket’ object has no attribute ‘readline’
It looks like usocket.socket does not have a readline attribute.
And I got stuck there, sorry for the long comment, I thought sharing this might help we have urequest faster on OpenMV.
Thank you
The text was updated successfully, but these errors were encountered:
So the errors I get which might happen to others too;
Here is my code;
url = “http://www.X.com/upload.php/” #url of the webpage which works in Spyder!
headers = {
‘User-Agent’: ‘Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:55.0) Gecko/20100101 Firefox/55.0’,
}
file = {‘file’: open(‘0.png’, ‘rb’)} #open file to post
r = urequests.post(url, files=file, headers=headers) #post request of file to url
print(r.status_code) #status code 200 means success
c = r.content #content of the response in bytes
print(c) #prints units
First error:
TypeError: function takes 2 positional arguments but 4 were given
in line 53 of the new urequest.py code:
ai = usocket.getaddrinfo(host, port, 0, usocket.SOCK_STREAM)
I removed the 0 and usocket.sock_stream so this was resolved
2nd error:
TypeError: object with buffer protocol required
some forums suggested changed it to json and it was resolved;
r = requests.post(url, json=file, headers=headers)
3rd error;
AttributeError: ‘socket’ object has no attribute ‘readline’
It looks like usocket.socket does not have a readline attribute.
And I got stuck there, sorry for the long comment, I thought sharing this might help we have urequest faster on OpenMV.
Thank you
The text was updated successfully, but these errors were encountered: