Inside this zip file is brython.js and brython_stdlib.js. To get an interactive shell in a webpage, create a .html file with a text editor and copy/paste the following code:
Open this .html in your browser to view the interactive shell:
The Brython zip file you downloaded also has a demo.html file that showcases many examples of Python code that can interact with the Document Object Model (DOM). Instead of putting JS code inside of a
<script type="text/python"> tag, you put Python code inside of a
<script type="text/python"> tag.
You can also install Brython as a module to your Python installation using pip. Run
pip install brython. This installs a brython-cli script. When you run
brython-cli install, the script creates the following files in the current directory:
If you run
python -m http.server to run a web server on your computer, then open your browser to the address
http://localhost:8000 you will see the contents of index.html rendered in the browser. Right-click the web page and select View Source (or open index.html in a text editor) to view the Python code being run by Brython:
To create client-side web apps that run in the browser, you'll have to learn Brython's API for interacting with the DOM. This is explained in detail in the Brython documentation.
You can also check out this PyCon 2014 talk by Susan Tan, Python in the Browser: Intro to Brython