'pansa2 already linked this upthread, but a colleague of mine wrote an in-depth comparison of six popular Python-in-the-browser implementations, and their trade-offs (with sample code). It's a writeup from a PyCon UK talk: https://anvil.works/blog/python-in-the-browser-talk