ewpratten / whython

A small utility for writing inline Python in webapps

Home Page:http://ewpratten.retrylife.ca/whython/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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".

About

A small utility for writing inline Python in webapps

http://ewpratten.retrylife.ca/whython/

License:GNU General Public License v3.0


Languages

Language:Ruby 81.8%Language:JavaScript 14.1%Language:HTML 4.1%