Important things about Pyscript
1. Let’s Create our first program with Pyscript
You can download the alpha release of PyScript on pyscript.net. We’ll use the CDN of one stylesheet and one script in our HTML file. Add below CDNs to your HTML <head>.
Our Hello world program will look something like this:
When you run this HTML file into your browser, it will print Hello World. Something like this:
2. Print Current Date Time
In the above example, we are using python’s DateTime library for current DateTime.
3. Bokeh Chart with Pyscript
Let’s create a chart to display the number of fruits sells during a month.
When you run this code, you will see a chart like;
As you see how easily we can create a graph into our HTML file only. There is no need to create complex components to display a chart like this. That’s how simply you can use Pyscript to run python in HTML.
This project is still in the alpha stage, so maybe we can see many more new things in the upcoming days. Pyscript looks very promising for python developers, but there might be a lot of security issues. Also, we are running Python libraries into the browser, so execution time is also high.
All these concerns might be resolved in upcoming releases. Comment down your thoughts about this new technology.