Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Developing a web page to run python scripts

Tags:

python

pexpect

I'm trying to develop a web-page that enable the user to write python code, and run that code with the ability to interact with it if it requires input. Its actually like a virtual console to run python code.

I found that pexpect can do that but locally on the system terminal. What I need to do is to use pexpect functionalities to make an online virtual console that runs python code.

What I had in mind is to write the buffer of the process run by pexpect into a file and run another script that continuously checks the file and display the data inside it. But I think that this is a very bad solution and costly in terms of accessing and writing files to the secondary memory.

Any ideas how to use pexpect or another approach to do that would be appreciated.

Thanks in advance.

like image 893
askso Avatar asked Apr 20 '26 02:04

askso


1 Answers

katrielalex points out quite rightly that you need to think very hard about security before deciding that this is a good idea, and that there is prior art.

  • There's an implementation using GAE here
  • The werkzeug web server includes an interactive python console in its stack traces for debugging.
like image 188
kdt Avatar answered Apr 23 '26 00:04

kdt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!