Skip to content

Adding urequest to OpenMV board #421

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Paryavi opened this issue Apr 29, 2021 · 0 comments
Closed

Adding urequest to OpenMV board #421

Paryavi opened this issue Apr 29, 2021 · 0 comments

Comments

@Paryavi
Copy link

Paryavi commented Apr 29, 2021

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

@Paryavi Paryavi closed this as completed Aug 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant