Brython
lastmod 2022-02-13created 2021-07-272 edits
A browser implementation of Python 3
Features
- "Browser Python"
- A Python 3 implementation that can access the browser's DOM objects and events
- Can run scripts in Python instead of JS on web pages
- Supports the latest HTML5/CSS3 specs as well as jQuery, D3, Bootstrap, LESS, SASS, etc.
Example
Here is a simple example of an HTML page running Python:
<html>
<head>
<script type="text/javascript" src="/path/to/brython.js"></script>
</head>
<body onload="brython()">
<script type="text/python">
from browser import document, alert
def echo(event):
alert(document["zone"].value)
document["mybutton"].bind("click", echo)
</script>
<input id="zone"><button id="mybutton">click !</button>
</body>
</html>