简体   繁体   English

开发一个网页来运行python脚本

[英]Developing a web page to run python scripts

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. 我正在尝试开发一个Web页面,使用户能够编写python代码,并运行该代码,并在需要输入时与其进行交互。 Its actually like a virtual console to run python code. 它实际上就像一个运行python代码的虚拟控制台。

I found that pexpect can do that but locally on the system terminal. 我发现pexpect可以在系统终端本地执行此操作。 What I need to do is to use pexpect functionalities to make an online virtual console that runs python code. 我需要做的是使用pexpect功能来创建一个运行python代码的在线虚拟控制台。

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. 我想到的是将pexpect运行的进程的缓冲区写入文件并运行另一个脚本,该脚本不断检查文件并显示其中的数据。 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. 任何想法如何使用pexpect或其他方法来做到这一点将不胜感激。

Thanks in advance. 提前致谢。

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. katrielalex非常正确地指出,在决定这是一个好主意之前,你需要非常认真地考虑安全性,并且有现有技术。

  • There's an implementation using GAE here 有使用GAE的实现在这里
  • The werkzeug web server includes an interactive python console in its stack traces for debugging. werkzeug Web服务器在其堆栈跟踪中包含一个交互式python控制台,用于调试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM