importing the requests module #1163
-
I tried the following:
with an error: What is the best way to implement the requests? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hello @visjble thank you for creating this discussion! There are a few different ways you can do this. If you want to use <py-config>
packages = ["requests", "pyodide-http"]
</py-config>
<py-script>
import pyodide_http
pyodide_http.patch_all()
import requests
url = 'https://jsonplaceholder.typicode.com/posts/2'
data = requests.get(url)
print(data)
</py-script> This is the easiest way to do it. Alternatively, you can create your own requests module following the great guide created by @JeffersGlass - How to make HTTP requests using Please let us know if this solves your problem 😄 |
Beta Was this translation helpful? Give feedback.
Hello @visjble thank you for creating this discussion!
There are a few different ways you can do this. If you want to use
requests
you can installpyodide-http
and patch requests. Here's an example code of what I mean:This is the easiest way to do it. Alternatively, you can create your own requests module following the great guide created by @JeffersGlass - How to make HTTP requests using
PyScript
, in pure Python.Please let us know if this solves …