Skip to content

Latest commit

 

History

History
65 lines (44 loc) · 2 KB

pyscript_muffin_sesh.md

File metadata and controls

65 lines (44 loc) · 2 KB
marp theme paginate transition _class backgroundColor backgroundImage
true
gaia
true
slide
lead

Publishing model/data-vis apps with pyscript, panel, and github-pages


Motivation

  • our team have a few (two?) R Shiny apps
  • intended for non-technical users, but have had difficulty in making them accessible

PyScript

  • https://pyscript.net/
  • PyScript lets you create a frontend web application using Python.
  • Either
    • embed Python code in HTML print('Hello World!') | , or
    • link to a Python file and the code will run in the browser.
  • developed by Anaconda people

How does it work?

PyScript sits on top of:

  • pyodide: Python ported to ...

    • WebAssembly: open standard for executing fast binary code in web apps.
  • pyodide packages include:

    • numpy, pandas, scipy, scikit-learn
    • matplotlib, bokeh, ...
    • and can use any pure Python packages from PyPi

A proof of concept

  • one of our shiny apps converted to Python, using Panel for widgetty things. https://panel.holoviz.org/
  • https://github.com/Treasury-Analytics-and-Insights/pyscript_experiment
  • an "Action" in the github repo publishes the app to github-pages whenever the main branch is updated
  • I think I just clicked a button in github to enable github-pages for the repo, and then added the Action by clicking "new Action" and selecting the "publish to github-pages" template. I didn't have to write any code for the Action.

Limitations

  • this github free account plus github-pages treatment is only suitable for non-sensitive data
  • if your app needs to import data from file, you can't just email the html and supporting files to someone, they need to run a local web server. For security, web browsers can't access local files without user permission. There are probably ways around this, but I haven't looked into it.