This github repo is an implementation to run python in the browser using flask.
Here is how the code works:
- The client sends the code to the flask server.
- The flask server writes the code to
output.py
and runs the program usingsubprocess.Popen(["python3 output.py"], shell=True)
. Note the the flask server makes some changes to the code so that the output is written tooutput.txt
- Now, the client sends lots of requests to
output.txt
, the file that the output of the program is written too. The client recieves the data and shows it on the page. The client keeps updating the output until the program is finished.