Python on the web
Filipe Fernandes
Dec 08, 2022
What are our needs?
Please keep this in mind as we navigate this presentation.
Python on the web is not a new idea. There were many, attempts with different degrees of success, in the past years.
https://discuss.streamlit.io/t/what-happened-to-streamlit-cloud-plans/24894
Wasm is the closest we ever got to a universal binary.
We need to be able to:
<link rel="stylesheet" href="https://pyscript.net/latest/pyscript.css" />
<script defer src="https://pyscript.net/latest/pyscript.js"></script>
and a pyscript tag,
<b><p>Today is <u><label id='today'></label></u></p></b>
<br>
<div id="pi" class="alert alert-primary"></div>
<py-script>
import datetime as dt
pyscript.write('today', dt.date.today().strftime('%A %B %d, %Y'))
def compute_pi(n):
pi = 2
for i in range(1,n):
pi *= 4 * i ** 2 / (4 * i ** 2 - 1)
return pi
pi = compute_pi(100000)
pyscript.write('pi', f'pi is approximately {pi:.3f}')
</py-script>
But… Before we dive into that…