Brython with Python😎
Running python on the client-side in the browswer using Brython
Brython is a Python 3 implementation for client-side web programming
Brython is designed to replace Javascript as the scripting language for the Web. As such, it is a Python 3 implementation (you can take it for a test drive through a web console), adapted to the HTML5 environment, that is to say with an interface to the DOM objects and events.
With Brython you can do a lot, example is listed below:
1. manipulate the dom
2. using the local storage
3. making ajax call using python…all without javascript
4. bind elements to events
5. select elements from DOM
6. create alerts
7. insert into the dom
8. bind to text elements
9. use variables
10. make ajax requests or http request
11. load files and show their content
12. manipulate css
13. adding and removing from local storage e.t.c
Goto brython.info (check out the demo, documentation, community)
You can download the brython source file on the website or use the CDN
https://cdnjs.cloudflare.com/ajax/libs/brython/3.8.8/brython.js
https://cdnjs.cloudflare.com/ajax/libs/brython/3.8.8/brython_stdlib.js
Create your html file and add some styling to it
add the onload=’brython()’ to the body tag
Make use of id in your html tags because thats how you can relate with python
Then add a script tag and set the type to type=”text/python” then give it an id
Note all functionalities have their different ids
So to code more functionalities to your html file simply add another script tag with another id and write your new function with python.
To get a boost ahead on Brython you can check out my github repo for some code.
Thank you for reading!
Cheers