3

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.

4 Answers4

3

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.

Community
  • 1
  • 1
jfs
  • 399,953
  • 195
  • 994
  • 1,670
  • Thanks for the link to SymPy. Looks useful. I might be able to fork the project and get something up suitable for my needs. Also +1 to PyPy's sandbox link. There is a lot in that answer. Thanks a lot. –  Aug 05 '12 at 04:35
3

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.

Sean Vieira
  • 155,703
  • 32
  • 311
  • 293
  • Thanks. I did check it out and will see if it is easier than getting something up using J.F. Sebastian's answer. –  Aug 05 '12 at 04:36
1

Have a look at the new python shell provided by Datacamp.Its great and has a nice design. Check here!

Rahul
  • 2,580
  • 1
  • 20
  • 24
0

Try This. It is a Python to javascript compiler. Never used it, but I've heard about it before. GLHF

Snakes and Coffee
  • 8,747
  • 4
  • 40
  • 60