[Tutor] Starting a browser instance and passing a parameter to it.

Alan Gauld alan.gauld at btinternet.com
Thu Nov 29 10:10:34 CET 2007

"Don Taylor" <nospamformeSVP at gmail.com> wrote

> I have this code:
> import webbrowser
> webbrowser.open("file:///D:/EclipseWS/XML-RPCTesting/webbrowser.htm?open=8001")
> when executed it does bring up the web-page ok, but the parameter
> (?open=8001) is lost.  If I try the same thing with an http url then 
> it
> works as expected.  However, I do not want to run a web-server on my
> machine.
> Is there any way I can get a browser to display a web-page from a
> file-based url and pass a parameter to the code running in that 
> page?

I don't think so because the file protocol does not support the
GET/POST methods of http. You could maybe change the
JavaScript to prompt for the value but it would be much easier
to just run a web srver on an unusual port - maybe the simple
web server that comes with Python.

> FWIW.  I am trying to use a web page as the GUI for a Python 
> program.
> The Python program is started in the usual way and it initiates its 
> web
> page GUI.  The Javascript in the web page then communicates with the
> Python program using XML-RPC.  The parameter I need to pass is the 
> port
> number to be used for this communication.

What are you using for the XML-RPC server? Doesn't that need to be a
web server of some sort anyhow? XML-RPC communicates using http...

You seem to be making a fairly easy task very complicated.

Alan G.

> I am currently using WinXP/Firefox but I want this to work on all
> platforms and browser combos.

Remember that portable JavaScript is quite hard to write due to 


Alan G 

More information about the Tutor mailing list