pyscript icon indicating copy to clipboard operation
pyscript copied to clipboard

The novice tutorial reports no patch() attribute

Open ChinaGodzilla opened this issue 2 years ago • 2 comments

Checklist

  • [X] I added a descriptive title
  • [X] I searched for other issues and couldn't find a solution or duplication
  • [X] I already searched in Google and didn't find any good information or help

What happened?

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width,initial-scale=1" />

        <title>Requests Tutorial</title>

        <link rel="stylesheet" href="https://pyscript.net/latest/pyscript.css" />
        <script defer src="https://pyscript.net/latest/pyscript.js"></script>
    </head>
    <body>
      <py-config>
        packages = ["requests", "pyodide-http"]
      </py-config>

      <py-script>
        import requests
        import pyodide_http

        # Patch the Requests library so it works with Pyscript
        pyodide_http.patch()

        # Make a request to the JSON Placeholder API
        response = requests.get("https://jsonplaceholder.typicode.com/todos")
        print(response.json())
      </py-script>
    </body>
</html>

URL:https://docs.pyscript.net/latest/tutorials/requests.html

image

What browsers are you seeing the problem on? (if applicable)

No response

Console info

No response

Additional Context

No response

ChinaGodzilla avatar Mar 18 '23 02:03 ChinaGodzilla

Thank you for raising this issue, I have #1264 which fixed this tutorial, unfortunately it seems we didn't merge it before we did the release.

FabioRosado avatar Mar 20 '23 09:03 FabioRosado

For context I have fixed the tutorial and the fix is live in the unstable version of the docs: https://docs.pyscript.net/unstable/tutorials/requests.html

But we need to deploy so this fix is pushed to the latest version 😃

FabioRosado avatar Apr 14 '23 10:04 FabioRosado

I hope we deployed in the meantime 😅

WebReflection avatar Jan 11 '24 14:01 WebReflection