0

I'm trying to figure out the best and most secure way to implement a shell that interacts with a web app. Here's the outline of an example problem:

1- There are several objects residing in a javascript array (e.g. [obj1, obj2, ...]) and each has a set of methods (e.g. obj.setName(name), obj.getName()).

2- I'd like to have an input field where the user can interact with the objects in a python-like language:

o = webApp.getObjByIndex(0)
print(o.getName())

As far as I can tell, my main option is to build a simple interpreter in javascript where it gets input lines one-by-one, parses it and then try to execute it. However it gets quickly complicated when implementing more features like a for loop.

My questions are:

  • Is there a better way? Are there tools for creating domain specific languages (DSL) that javascript can understand?
  • Is it possible to implement two-way python-javascript interaction in a web app?
  • I'm sure there must be website implementing similar ideas. Do you know any good examples?

Thanks.

user31208
  • 1,448
  • 1
  • 18
  • 22
  • All browsers have a JS console already. Certainly if you have a user tech savvy enough to write JS, they can figure out how to open the JS console and write their code there. – Preston S Dec 18 '14 at 17:18
  • Well, the shell is supposed to be part of the main interface of the web page, where it replaces many buttons and widgets. I prefer users not open a JS console to use the website. Plus, the audience are scientists who generally know python and I think a python pseudo-shell will be familiar for them. – user31208 Dec 18 '14 at 17:31
  • You probably won't find a python interpreter but this [question](http://stackoverflow.com/questions/195149/is-it-possible-to-sandbox-javascript-running-in-the-browser) might be useful to you. – Preston S Dec 18 '14 at 17:33
  • Thanks! I found it interesting. – user31208 Dec 18 '14 at 17:38

0 Answers0