1.2.0 • Published 5 months ago

py-in-browser v1.2.0

Weekly downloads
-
License
ISC
Repository
-
Last release
5 months ago

py-in-browser

This package is a python--web-assembler built for the web using Pyodide

Features

  • Write and execute Python code directly in the browser.
  • Utilizes Pyodide to run Python code using a WebAssembly build of the CPython interpreter.
  • Provides a simple and interactive development environment for Python.

Getting Started

Installation

Install the package using npm:

npm install py-in-browser

Add cross origin policy in headers:

'Cross-Origin-Opener-Policy': 'same-origin','Cross-Origin-Embedder-Policy': 'require-corp','Cross-Origin-Resource-Policy': 'same-site',

Import the package into your JavaScript/TypeScript code:

const { initializeWorker, runcode } = require("py-in-browser");

Initialize the worker(initialization of pyodide):

initializeWorker(callbackfunction);

Execute Python code:

const code = print('hello world')

Call the runcode method:

runcode(code);

Define the callback function to handle the output from Python code execution:

function callbackfunction(text){ let output += text; console.log(output); }

1.2.0

5 months ago

1.1.5

5 months ago

1.1.4

8 months ago

1.1.3

8 months ago

1.1.2

8 months ago

1.1.1

8 months ago