Feb-19-2023, 02:15 PM
(Feb-19-2023, 03:18 AM)Skaperen Wrote: how hard would it be to integrate CPython in a web browser? how secure could be made to run?It already done in PyScript.
It's use Pyodide underneath.
Quote:What is Pyodide?
Pyodide is a port of CPython toWebAssembly
/Emscripten.
Just open this
index.html
in browser<!DOCTYPE html> <html lang="en"> <head> <script defer src="https://pyscript.net/alpha/pyscript.js"></script> </head> <body> <py-script>print("Hello, World!")</py-script> <py-script> def multiply_num(num): return num * 8 result = multiply_num(8) print(result) </py-script> </body> </html>
Output:Hello, World!
64
<head> <script defer src="https://pyscript.net/alpha/pyscript.js"></script> </head> <py-env> - numpy - matplotlib - pandas </py-env> <py-script> import pandas as pd import matplotlib.pyplot as plt import numpy as np df = pd.DataFrame(np.random.rand(10, 4), columns=["a", "b", "c", "d"]) fig, ax = plt.subplots() df.plot.area(ax=ax) plt </py-script>
![[Image: naMD1O.png]](https://imagizer.imageshack.com/v2/xq90/922/naMD1O.png)