FrontEnd web
Published in

FrontEnd web

Python

What is Brython?

I deep love for Python and Javascript. I'm always trying to find a solution to run the python directly inside the web browser. One day luckily, I found a youtube video by Traversy Media. Traversy media tells us about Brython with the demo. You use Brython to write python code directly inside the browser.

After I became more curious about Brython, I learned more about Brython(Browser Python).

python language
Photo by George Stewart on Unsplash

Whats is Brython(Browser Python)?

Brython is a new library written in python3. Use Brython, and you run python directly inside your web browser. The Brython aims to replace the javascript.

Brython is a new way of javascript. Brython is easy to understandable and usable. You easily interact with dom(Dom Object Model) and change dom help of python.

Main features

Brython supports most of the syntax of Python 3, including generators, metaclasses, imports, etc., and many modules of Python.

It supports the latest specs of HTML5/CSS3, and also you use CSS Frameworks like Bootstrap 3, LESS, SASS, etc.

How to install Brython?

You install Brython very easily help of pip and CDN.

using pip:

pip install brython

Then create an empty folder/ directory and run the following command.

brython-cli --install

If Brython-cli does not work. then follow this command

python -m brython --install

Folder structure

The folder structure looks like

Run the Web server app

Run webserver locally use of python.

python -m http.serverorpython -m http.server 8001

After some time, Brython launches the new version. You update Brython's with two commands.

pip install brython --upgrade
brython-cli --update

Now you start working on Brython.

Using CDN:

You use Brython's help of CDN (Contact delivery network). You copy CDN links on the official Brython website. after paste links inside your HTML page.

<script src="https://cdn.jsdelivr.net/npm/brython@3.9.0/brython.min.js"> </script> <script src="https://cdn.jsdelivr.net/npm/brython@3.9.0/brython_stdlib.js"> </script>

Update your Brython. Just change CDN links on your site.

How to use Brython?

Use Brython very easily inside your project. follow all steps

  1. Firstly, install Brython help of CDN and npm.
  2. Secondly, Call the function brython() on page load, like <body onload="brython()">.
  3. Write Python code inside script tags. <script type="text/python">.
<body onload="brython()" >   <script type="text/python"> # write python code here </script></body>

Hello World Example

In the Hello World example, you show hello world inside the dom.

Hello world example

Mouse Event Example

Mouse Event Example you understand the basics of event handling in Brython

mouse example

Alert Example

In this Alert example, I Create an alert in the browser

alert example

Dialog box example

In this example, I create a dialog box in the browser use of python

dialog box example

Future of Brython

In my opinion, Brython's future is not clear. Every New Technology Coming with own thought. Brython Launch official Nav 22 2016.

After 4-year Brython did not create a big impact on the developers' community. Maybe in the future developer's mind change. The developer shows more interested in Brython.

Conclusion

You write python code and run it directly inside the web browser. But Brython does not replace clear javascript.

You use Brython to handle the frontend and backend in one place. I think this feature is very cool for me.

If you hire me, then follow me on Upwork and Fiverr.

Fiverr:
https://www.fiverr.com/users/officialrajdeep/

Upwork:
https://www.upwork.com/freelancers/~01a4e8ba7a41795229

--

--

--

FrontendWeb is a platform for writers and readers to read and write a new post about frontend developers, full-stack developers, Web developers, and Computer science. It is an open-source community that join and gathers frontend developers to build and share knowledge with others

Recommended from Medium

Deep Learning Software Setup with GPU

Vietnam for offshore software development

🚀 Bitfrost Lunar Airdrop 🎁 Get up to 1000 BFC_K ($38) 🔘 Markrt: Upbit, Uniswap…

What to Expect After Code School, Part 1: I Graduated! Now What?

How to: Get started on ViewsHub

My First Experience Contributing to Open Source Software

Concatenate Strings in Kotlin...Behind the scene(1/4)🎃

How to make your database highly available (HA)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Rajdeep singh

Rajdeep singh

JavaScript || Reactjs || Nextjs || Python || Rust || Biotechnology || Bioinformatic || Front-end Developer || Writer || https://officialrajdeepsingh.dev/

More from Medium

Fundamentals of JavaScript, Version Controlling, NoSQL | A Reflective Overview

Unlock possibilities with GitHub REST APIs

Top Javascript Frameworks

How to Setup GitHub “Pages” and Shave Hours Off of Project-Prep