What is PyScript in Web Application?

·

2 min read

According to the most recent announcement from Anaconda, the Python makers for scientific computing has initiated a python script called "PyScript" that can run in the browser, in HTML files as what Javascript did.

Traditionally, the snake language interacts with Javascript on the webpage by running as an application server to return HTML and JS. With PyScript, web developers can run in the browser using Python and standard HTML files.

How it works According to one of the Anaconda team, Peter Wang mentioned "a system for interleaving Python in HTML". It means web developers can write and run Python code in HTML, call Javascript libraries using PyScript, and do all their web development using Python. Pyscript is dependent on Pyodide, which is a port of CPython runtime to WebAssembly.

What is WebAssembly? WebAssembly was first released in 2017 and became the official World Wide Web Consortium (W3C) standard by 2019. It uses .wat text format language and is converted into a binary .wasm format that browsers can run. This allows us to write code in any language, compile it to WebAssembly, and then run it in a web browser.

Anaconda’s goal for PyScript is to give users a first-class programming language that has consistent styling rules, is more expressive and is easier to learn.

Key things to learn more about PyScript are:

  • In the browser: enable drop-in content, utilizing external file hosting, and application hosting without using an existing server-side configuration
  • Eco-system: operated in many popular packages of Python script and scientific stack (such as Pandas and NumPy)
  • Relationship with JavaScript: bi-directional communication between Python and Javascript objects and namespaces
  • Environment management: allow users to define which packages and files
  • Visual application development: use available curated UI components, such as buttons, containers, text boxes, and more
  • Framework: flexible that can be leveraged to create plugins and extensible components directly in Python

Please note that PyScript is in the developing stage and not ready for the public.

Did you find this article valuable?

Support Bill Wee by becoming a sponsor. Any amount is appreciated!