Pytml

Pytml is a 15KB lightweight PyScript alternative — run Python in HTML with one script tag.

git clone https://github.com/notamitgamer/Pytml.git
· rebuilt hourlyOpen on GitHub
commit a5fadffc922fb7d701e88f186e9272171558ac03
parent 8cbfa272198f0ac20f7baf89fbe8e4699d578e79
Author: ASWANTH R <aswanthr82@gmail.com>
Date:   Mon, 19 Oct 2026 16:31:15 +0530

Enhance event handler for async callback support

Updated event handling to support asynchronous callbacks.
Diffstat:
Mpytml.js | 6+++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/pytml.js b/pytml.js @@ -158,6 +158,7 @@ fetch('https://pytml.vercel.app/api/count', { // This is the Python-side DOM/runtime module injected into Pyodide at startup. const PYTHON_MODULE = String.raw` import js +import asyncio from pyodide.ffi import create_proxy _callbacks = [] @@ -273,7 +274,10 @@ class Element: def handler(raw): try: normalized = js.pytmlInstance.api_event(raw).to_py() - return callback(Event(normalized, raw)) + result = callback(Event(normalized, raw)) + if asyncio.iscoroutine(result): + asyncio.ensure_future(result) + return None except Exception: import traceback js.pytmlInstance.addError(traceback.format_exc())