Skip to content
This repository has been archived by the owner on Jul 16, 2021. It is now read-only.

ewpratten/whython

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

whython

A small utility for writing inline Python in webapps

How it works

whython is a small JavaScript script that does the following:

  • Loads Pyodide
  • Searches for script tags with the content type application/python
  • Resolves any remote scripts
  • Opens a new Python scope for each script, and executes it

whython is basically just a wrapper for Pyodide.

How to use whython

Using whython is simple:

<script src="https://ewpratten.retrylife.ca/whython/static/js/whython.js"></script>
<script type="application/python">
import sys
print(sys.version)
</script>

<!-- Or -->
<script src="https://ewpratten.retrylife.ca/whython/static/js/whython.js"></script>
<script type="application/python" src="/path/to/script.py"></script>

Since whython is based on Pyodide, see the pyodide documentation for information on loading packages, and accessing DOM.

What's with the name?

My friends know all too well that I have an obsession with running Python on unusual platforms. It has gotten to the point where every time I say "hey, guess what I got Python to run on?", I'm just met with collective sighs, and generally someone saying "but why?". Also, the w was supposed to stand for "web".

Releases

No releases published

Sponsor this project

 

Packages

No packages published