Start Python at client side from web app
AbelCodeMonk at gmail.com
Wed Jan 28 08:37:25 CET 2009
> We create a custom mime-type and register it on the client PC. The web application
> can send signed python code to the client PC. If the signature is correct,
> the code will be executed at the client. The signature prevents others from executing
This will let you start a program from within the browser. It will not
let you run arbitrary Python inside the browser but it doesn't sound
like that's your goal.
If you goal is "user can go to site, click button, hit OK on
confirmation box, and launch arbitrary Python code", then the mime
type solution is probably the best bet. Just make your own custom
extension which will launch the python interpreter on your file. Give
it a mime type, and serve regular .py files with that extension and
mime type. IE will start the interpreter in a new process and pass
your file along.
To verify the file's signature, you could simply create a custom
interpreter by making a console app that takes a file, checks a sig,
then runs the file against an embedded interpreter. Embedding the
interpreter is simple enough.
> I can code this myself, but prefer to use some open source project, if it exists.
I don't know of any such.
Heck, if you don't care about checking the signature on the file
before running, your "project" could consist of a .reg file that sets
up your extension/file type/mime type. Do an MSI if you want to get
really fancy, but all you really need to do is add a couple entries to
Of course, everything's a lot harder if you want to run within the
browser. Having the browser ask the user for permission then launch a
new process is easy. Building an integrated experience that hosts
Python inside the browser sandbox is a lot harder - and probably not
More information about the Python-list