DEV Community

Cover image for pyscript : run python in HTML
Ajith R
Ajith R

Posted on

pyscript : run python in HTML

PyScript is a framework that allows users to create rich Python applications in the browser using HTML's interface and the power of Pyodide, WASM, and modern web technologies.

What is PyScript?
PyScript is a Python front-end framework that enables users to construct Python programs using an HTML interface in the browser.

How to Get Started with PyScript
PyScript is fairly easy and straightforward to learn. To get started, you can either follow the instructions on the website or download the .zip file.
Just Follow the steps that i have given on the next pages.

1. Create an HTML file

<!DOCTYPE html>



content="width=device-width, user-scalable=no, initial
scale=1.0, maximum-scale=1.0, minimum-scale=1.0">

Title: PyScript



2.Link PyScript

href="https://pyscript.net/alpha/pyscript.css" />

3.Print to browser
Now that you've linked PyScript to the HTML file, you can print your "Hello World".
You can do this with the tag. The tag allows you to run multi-line Python programs and have them printed on the browser page. Place the tag in between the tags.

print("Hello, World!")

4.The full code for the HTML file is below:

<!DOCTYPE html>



content="width=device-width, user-scalable=no, initial
scale=1.0, maximum-scale=1.0, minimum-scale=1.0">

href="https://pyscript.net/alpha/pyscript.css" /> Title: PyScript


print("Hello, World!")

5.On your browser, you should see this:
Hello, World!

Top comments (0)