4

I have written a module in python which performs some function.

I then created a Google Chrome extension which makes use of JSON and javascript.

Now when I click on the extension I want it to execute the python program which is stored on my hard disk and display the output on the browser again.

Is there a way in which I can do this??

5
  • 1
    Is the point of the extension to use chrome? Or are you just looking for an environment for your application? I am doing something quite similar using the Adobe Air SDK, which lets you call python scripts bundled with your app. It is a javascript / html environment which allows you to work with you local hard disk and local sockets / resources. Commented Mar 16, 2011 at 15:26
  • But I want it to be made available on the browser. Adobe Air SDK lets you create an interface on the browser? Commented Mar 16, 2011 at 15:41
  • No, it won't allow you to make it avaiable in another browser. It has it's own internal webkit based browser, which is installed as an air app or native application. Commented Mar 16, 2011 at 15:55
  • I have already created the plug in.. I just want to send data from the current web page to my python program residing on my hard disk . Is there a way I can do that? Commented Mar 16, 2011 at 16:00
  • No experience with chrome extensions, so can't help there unfortunately. Commented Mar 16, 2011 at 16:03

3 Answers 3

3

Repeated :

Calling Python from JavaScript

Here you have some answers, Pyjamas is probably the best option in your case

Sign up to request clarification or add additional context in comments.

2 Comments

I tried using pyjamas but it tries to convert the entire python script into a javascript. But my pyhton script uses NLTK and other such packages and hence the JS script gives errors
Then I think that there is no option , google-chrome doesn't provide a python interpreter and I suppose that no extension can do that job. Nonetheless you can do it for mozilla firefox with pyxpcomext.mozdev.org
2

Probably a late reply but a possible solution is to make your python script act as a server and let the browser plugin interact with it.

Comments

1

forgive me if i'm incorrect on infinite proportions.

I believe that JavaScript is executed in a sandboxed/ isolated environment. Therefore you cannot invoke a python interpreter* or any other executable residing on the system.

*unless the interpreter itself were written in javascript.

1 Comment

Oh okay. Can anyone suggest any other way of doing it? I am trying it since 2 weeks and I am not reaching anywhere :-(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.