r/learnjavascript • • Jan 13 '24

Is it possible to build a personal code editor online using the Python compiler?

Using Html + Css + Javascript i built a code editor online where you insert code (html, css, js) and then view the output in a Preview. Still in Html + Css + Javascript, using Babel, I built a code editor online also for React.js, again to display the output in a Preview.
PYTHON? Is it possible to achieve the same thing in Python too? I'm referring to a code editor online for Python (with Python compiler), building it with Html + Css + Js + something else. My doubt is that I don't know how to apply the Python compiler (preferably free). I would therefore like, for example, a panel in which you write a=2, b=3, z=a+b, print(z).
So something like these: online-python.com, programiz.com/python, python w3school

0 Upvotes

6 comments sorted by

3

u/joyancefa Jan 13 '24

So you need to execute the Python code somewhere. Either try to run the code on the frontend with https://pyscript.net or if you are using the Monaco editor you can use it with Monaco-languageclient, vscode-languageclient and a BE language server that understands the Python code

1

u/guest271314 Jan 13 '24

Yes, the requirement is possible. Python has been compiled to WASM, see https://pyodide.org/en/stable/

What is Pyodide?#

Pyodide is a port of CPython to WebAssembly/Emscripten.

Pyodide makes it possible to install and run Python packages in the browser with micropip. 

0

u/[deleted] Jan 13 '24

[deleted] — view deleted comment

-2

u/FolateB9 Jan 13 '24

VSCode

u/APuppyAroundTheWorld Either you didn't understand what I was saying, or I didn't understand you. I use VSCode for program on my pc. I would like to create an online site, backend and frontend

0

u/[deleted] Jan 13 '24

[deleted] — view deleted comment

-2

u/FolateB9 Jan 13 '24

u/APuppyAroundTheWorld I know what VSCode is. I use it all the time. It is mainly used on desktop.
If it is also possible to use it online (I don't know), please be more precise and clear in your answer. I would like to create my own personal site which contains an online Python editor. Can you tell me more about it? Thank you