问题
I am working on a manuscript for introducing programming to beginners. Python is one of the two languages I cover in this book. I would like to setup up a webpage with an embedded Python shell for my readers to go and try things out. What would be the best way to go about it? I am aware of web apps like repl.it. I would personally like to set something up myself, however.
回答1:
There is a sample google appengine project that provides Python shell e.g., http://live.sympy.org uses it.
Or your JavaScript code (an Ajax shell) could communicate with a sandboxed Pypy version using something like this Twisted WebSocket server.
回答2:
The fine folks at repl.it provide a version of Python that is compiled in JavaScript using LLVM and EmScripten - it's heftier than some of your other options (and possibly buggier) but it's completely client-side and therefore not vulnerable to some of the attacks that a server-side setup might be vulnerable to.
回答3:
Have a look at the new python shell provided by Datacamp.Its great and has a nice design. Check here!
回答4:
Try This. It is a Python to javascript compiler. Never used it, but I've heard about it before. GLHF
来源:https://stackoverflow.com/questions/11813301/embedding-a-python-shell-in-a-webpage