Skip to content

NodeX-AR/Pytml

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

181 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

PYTML - Python in Your Browser

Website GitHub stars License GitHub issues GitHub last commit SWH

Run Python in your browser with zero configuration – no server, just a script tag.

Pytml is a lightweight (~15KB) JavaScript library that acts as a bridge between Python and HTML via WebAssembly. Drop a single script tag into any static page, write your logic inside <py> tags, and it runs natively in the browser.


Quick Start

Add one line to your HTML:

<script src="https://pytml.vercel.app/pytml.js"></script>

Usage

Option 1: Inline Python (Recommended for mobile/local)

<!DOCTYPE html>
<html>
<head>
    <script src="https://pytml.vercel.app/pytml.js"></script>
</head>
<body>
    <py>
print("Hello, world!")
name = input("Your name? ")
print(f"Hi {name}!")
    </py>
</body>
</html>

Option 2: External Python File (HTTP/HTTPS only)

<!DOCTYPE html>
<html>
<head>
    <script src="https://pytml.vercel.app/pytml.js"></script>
</head>
<body>
    <script type="text/python" src="script.py"></script>
</body>
</html>
py
name = input("Enter your name: ")
age = input("Enter your age: ")
print(f"Hello {name}, you are {age} years old!")

Important for Local Users (file:// protocol)

If you're running HTML locally from your device (mobile or desktop):

Use inline tags — This is the only method that works with file:// protocol

Features

Zero config – just add one script tag

Real I/O – print() and input() work live in the browser

Full error tracebacks – debug like a local REPL

Package support – NumPy, Pandas, Matplotlib via micropip

Privacy-first – no code ever leaves your browser

15KB wrapper – Pyodide loads lazily, page isn't blocked

Links

Official Website

License

Pytml is open-source under the Apache 2.0 License.

Support

If you find Pytml useful, consider giving it a star on GitHub!