Getting Started with PyScript

Getting Started with PyScript

Create interactive web apps with Python in the browser.

rate limit

Code not recognized.

About this course

PyScript is a revolutionary platform for Python in the browser. Thanks to custom tags and extensions, PyScript enables users to embed standard Python code into a web page that runs directly into the browser with no installation required.

In this course, we will explore the main features of the PyScript platform. We will learn how PyScript works, and how to use it to create a rich web app in the browser with Python. We will work on multiple exercises as an opportunity to dive into specific PyScript features and functionalities, and to immediately see in practice what we have learned.

This course has been created based on the November 2023 PyScript release (i.e., release 2023.11.1), which brought lots of innovations and new features compared to any previous releases. To work on the apps we will be using PyScript.com, a flexible, free, and easy to use coding environment.

What you'll learn—and how you can apply it

By the end of this course, you’ll understand:

  • How to use PyScript for your interactive web apps
  • How PyScript works
  • How to develop and distribute your apps using PyScript.com

And you’ll be able to:

  • Use PyScript to create interactive web apps that make the best use of modern web technologies
  • Choose and customize PyScript's various features according to your use case
  • Create Python apps requiring zero-installation that can be shared with anyone (without having them install anything on their computers as a web browser is all that is needed)

This training is for you because…

  • You’re a Python developer and want to learn how you can use Python in the Browser.
  • You work with web technologies, and you want to bring your Python skills to the next level by also using Python in the front-end.
  • You want to become a PyScript power-user, learning how you can make better use of your Python experience.

Prerequisites

  • Experience with programming in Python is required to work on the materials of this course. In particular, you should be familiar with Python basic data structures, and language constructs (e.g., for loops, conditionals, and functions).
  • No previous experience with web development is required to work on this course, but having some experience with HTML and the web would be a plus.

Recommended preparation

About the instructor

Valerio Maggio is a researcher and data scientist advocate at Anaconda. He is also an open-source contributor and an active member of the Python community. Over the last 12 years, he has contributed to and volunteered at many international conferences and community meetups like PyCon Italy, PyData, EuroPython, and EuroSciPy.

Questions? Issues? Contact [email protected].

Curriculum02:00:00

  • PyScript and Python in the browser
  • Introduction
  • Setting up and using PyScript
  • Exercise: writing your first PyScript app
  • print () function
  • PyScript architecture
  • <script type="py"> vs <py-script> (Optional lesson)
  • Module overview
  • Interactive apps
  • Interactive apps and foreign function interface (FFI)
  • Exercise: creating an interactive app
  • How the app works: the document object and JavaScript foreign function interface (FFI)
  • Web development and cross origin resource sharing CORS (Optional lesson)
  • Module overview
  • Browser as a computing platform
  • Your browser is your most ubiquitous computing platform
  • Exercise: 3D Plotting with NumPy and Matplotlib with PyScript and Pyodide
  • Interactive 3D Voxel Plots
  • Organizing code into modules
  • How it works: Pyodide packaging, interactivity, and FFI with Pyodide
  • Runtime threads, interactivity, and blocking calls (Optional lesson)
  • Module overview
  • Conclusion
  • End of Course Survey

About this course

PyScript is a revolutionary platform for Python in the browser. Thanks to custom tags and extensions, PyScript enables users to embed standard Python code into a web page that runs directly into the browser with no installation required.

In this course, we will explore the main features of the PyScript platform. We will learn how PyScript works, and how to use it to create a rich web app in the browser with Python. We will work on multiple exercises as an opportunity to dive into specific PyScript features and functionalities, and to immediately see in practice what we have learned.

This course has been created based on the November 2023 PyScript release (i.e., release 2023.11.1), which brought lots of innovations and new features compared to any previous releases. To work on the apps we will be using PyScript.com, a flexible, free, and easy to use coding environment.

What you'll learn—and how you can apply it

By the end of this course, you’ll understand:

  • How to use PyScript for your interactive web apps
  • How PyScript works
  • How to develop and distribute your apps using PyScript.com

And you’ll be able to:

  • Use PyScript to create interactive web apps that make the best use of modern web technologies
  • Choose and customize PyScript's various features according to your use case
  • Create Python apps requiring zero-installation that can be shared with anyone (without having them install anything on their computers as a web browser is all that is needed)

This training is for you because…

  • You’re a Python developer and want to learn how you can use Python in the Browser.
  • You work with web technologies, and you want to bring your Python skills to the next level by also using Python in the front-end.
  • You want to become a PyScript power-user, learning how you can make better use of your Python experience.

Prerequisites

  • Experience with programming in Python is required to work on the materials of this course. In particular, you should be familiar with Python basic data structures, and language constructs (e.g., for loops, conditionals, and functions).
  • No previous experience with web development is required to work on this course, but having some experience with HTML and the web would be a plus.

Recommended preparation

About the instructor

Valerio Maggio is a researcher and data scientist advocate at Anaconda. He is also an open-source contributor and an active member of the Python community. Over the last 12 years, he has contributed to and volunteered at many international conferences and community meetups like PyCon Italy, PyData, EuroPython, and EuroSciPy.

Questions? Issues? Contact [email protected].

Curriculum02:00:00

  • PyScript and Python in the browser
  • Introduction
  • Setting up and using PyScript
  • Exercise: writing your first PyScript app
  • print () function
  • PyScript architecture
  • <script type="py"> vs <py-script> (Optional lesson)
  • Module overview
  • Interactive apps
  • Interactive apps and foreign function interface (FFI)
  • Exercise: creating an interactive app
  • How the app works: the document object and JavaScript foreign function interface (FFI)
  • Web development and cross origin resource sharing CORS (Optional lesson)
  • Module overview
  • Browser as a computing platform
  • Your browser is your most ubiquitous computing platform
  • Exercise: 3D Plotting with NumPy and Matplotlib with PyScript and Pyodide
  • Interactive 3D Voxel Plots
  • Organizing code into modules
  • How it works: Pyodide packaging, interactivity, and FFI with Pyodide
  • Runtime threads, interactivity, and blocking calls (Optional lesson)
  • Module overview
  • Conclusion
  • End of Course Survey