On April 30, 2022, Peter Wang, CEO of Anaconda, introduced PyScript, a new framework that brings the Python language into HTML and the web browser. The framework allows developers to create Python applications directly in the browser without requiring a server backend.
<html> <head> ... # Include PyScript CSS and JS <link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" /> <script defer src="https://pyscript.net/alpha/pyscript.js"></script> </head> ... <py-script> print("Hello world!") </py-script> ... </html>
The PyScript project offers many important features and benefits beyond the ability to author Python in HTML documents:
scikit-learn, all in the browser.
After many years of chaos and growing pains including the browser wars, the dot com bubble, and the development of Web 2.0, the web has stabilized into a rock-solid platform. The web is itself cross-platform and backwards compatible. Sites that ran 10 years ago will still run today. While the PyScript project is still new, it is also quickly maturing and stabilizing. One might argue that, in the near future, PyScript will become the most reliable way to create and distribute data-centric projects.
See Packages built in Pyodide for more.
Since PyScript projects are simply HTML documents, sharing complex applications becomes far more simple than the sharing of a traditional project. Want to show off your work to a colleague? You can email the file or drop it into Slack. You can run a local server (
python -m http.server) and use something like ngrok to send a public URL to your friend. No spinning up an environment or virtual machine.
Ready to publish your project? Deployment is as easy has hosting a static website. No devops, no Linux administration, no Docker or Kubernetes. If you can host a simple "Hello World" web page, you can publish a PyScript project.
By bringing Python into the browser, the "how did they do that" of a data-centric app becomes as accessible as clicking "View Source" in the browser. Before YouTube, blogs, and bootcamps, early web practitioners, such as myself, learned our craft by viewing the source of other people's work. In fact, I would personally credit the ability to view the source of any website as a key contributor to the rapid growth of the early web. The ability to view the source of PyScript projects is huge.