The PyScript Gallery is a website with browseable, runnable examples.
But wait -- it's also a running Python
application
! You can run it with
pipx
or a local
virtualenv! It's also a Python
package
. You can install it into your own project and run it from there.
Let's look at the ways different kinds of uses can run the Gallery.
Viewer
Go to the website, click the link, and PyScript runs the Python code in your browser. Yeh, duh, we all know that.
Coder
What if you want to run offline? Or poke around locally? It's a Python package, and
pipx
makes it
easy to run applications. This will fire up a local Starlette server.
Everything
-- including Pyodide -- will be served
locally. (Unless one of the examples has to make an API request.)
You'll get the same Gallery you're seeing on the website. It's just statically dumped from Starlette
Contributor
Maybe you're not up on
pipx
. Or maybe -- just maybe! -- you'd like to create and contribute an example.
Use virtualenv or Conda to make a project, install
psg
as a dependency.