Search code examples
pythonbrython

Embed Runnable Python in Web Page Using Brython


Inspecting the source of this page: https://snakify.org/en/lessons/two_dimensional_lists_arrays/ I noticed that it uses Brython (https://brython.info/).

I want to be able to embed runnable Python scripts in web pages for educational purposes. However the Brython website doesn't seem to explain how to do this. There are some great examples of brython running in a browser, but not as editable, pre-loaded code that users can edit and run.

Can anyone please explain how to achieve what I'm trying to do, or point me to some relevant info?


Solution

  • Both the site you refer to, as well as the brython site itself use ACE editor for that purpose. Check the source code. On the brython site there is also info how you can embed console instead

    EDIT (23 March 2020):

    An alternative is Monaco Editor by Microsoft. It is used by Repl.it and is used in VSCode.

    There is also CodeMirror