Python Library: pyscript

Run Python in Your HTML

Table of Contents
Library resources
Homepage https://pyscript.net/
PyPI ---
Github https://github.com/pyscript/pyscript
Documentation https://docs.pyscript.net/latest/

11 Dec 2022

Alpha release - "We encourage people to play and explore with PyScript, but at this time we do not recommend using it for production."

Getting Started

pyscript/pyscript-install.gif

"No installation required".

Seems pyscript runs "encapsulated" in Javascript (ie add link to pyscript JS file in <head> and script actions in `').

Usage

<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1" />

    <title>REPL</title>

    <link rel="icon" type="image/png" href="favicon.png" />
    <link rel="stylesheet" href="https://pyscript.net/latest/pyscript.css" />
    <script defer src="https://pyscript.net/latest/pyscript.js"></script>
  </head>

  <body>
    Hello world! <br>
    This is the current date and time, as computed by Python:
    <py-script>
from datetime import datetime
now = datetime.now()
now.strftime("%m/%d/%Y, %H:%M:%S")
    </py-script>
  </body>
</html>

links

social