Skip to content

DAGWorks-Inc/react-py

 
 

Repository files navigation

react-py react-py

Run Python code directly in the browser. Try it out!

CodeQL MIT License NPM Version NPM Bundle Size


Quickstart

Install react-py with:

npm i react-py

Then, wrap your app in a PythonProvider component.

import { PythonProvider } from "react-py";

function App() {
  return (
    // Add the provider to your app
    <PythonProvider>
      <Codeblock />
    </PythonProvider>
  );
}

render(<App />, document.getElementById("root"));

Using the usePython hook, you can run code and access both stdout and stderr. For full usage instructions, see the usage docs.

Documentation

For full documentation, visit elilambnz.github.io/react-py.

Examples

Basic example Interrupting execution

Limitations

Most of the Python standard library is functional, except from some modules. The following modules can be imported, but are not functional due to the limitations of the WebAssembly VM:

  • multiprocessing
  • threading
  • sockets

Learn more about the limitations here.

Roadmap

  • Add additional examples
  • Ability to run python in Web Workers
  • Extended API for custom configuration

License

react-py is available under the MIT License.

Contact

Eli Lamb - elilambnz
James Ansley - James-Ansley

Acknowledgments

This project is heavily based on Pyodide, a Python distribution for the browser and Node.js based on WebAssembly.

About

Run Python code directly in the browser.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 93.3%
  • JavaScript 6.7%