Fetch API with Dataclasses / Pydantic

Made a write-up on using Python dataclass / data model in the browser

Exciting that we can parse / validate data client-side with Python!

I am having issues with browser Fetch API not streaming results when deployed (works locally in PyScript and the endpoint works locally in a browser). Looked into web.dev “fetch-upload-streaming” and SO “how-to-handle-streaming-data-using-fetch” posts, but at this point might turn to websocket.

  • live site: notes-api.gerardbentley.com
  • curl streaming endpoint (works because of no-buffer): curl -N https://notes-api.gerardbentley.com/listen_notes

Locally working: