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
root / examples / packages.html

packages.html (883B)


      1 <!DOCTYPE html>
      2 <html lang="en">
      3 <head>
      4   <meta charset="UTF-8">
      5   <meta name="viewport" content="width=device-width, initial-scale=1.0">
      6   <title>Pytml Packages</title>
      7   <script src="https://pytml.vercel.app/pytml.js"></script>
      8   <style>body{font-family:system-ui;max-width:700px;margin:auto;padding:30px}button{padding:10px 16px;cursor:pointer}pre{padding:14px;background:#f4f4f5;border-radius:8px}</style>
      9 </head>
     10 <body>
     11 <h1>Packages</h1>
     12 <button id="run">Run NumPy</button>
     13 <pre id="output">Click the button to install NumPy and run Python.</pre>
     14 
     15 <py1>
     16 import micropip
     17 
     18 async def run_numpy(e):
     19     output.text = "Installing NumPy..."
     20     await micropip.install("numpy")
     21     import numpy as np
     22     values = np.array([1, 2, 3, 4])
     23     output.text = f"mean = {values.mean()}"
     24 
     25 run.on("click", run_numpy)
     26 </py1>
     27 
     28 <p><a href="../demo.html">← Back to demos</a></p>
     29 </body>
     30 </html>