Antonio Ceballos wrote: > Hello, > > I am trying to open a URL on a new browser or new tab from an HTML page > created from a python cgi script.
import cgitb; cgitb.enable() # Will save you hours of debugging. Prints error messages and exceptions to the client, wrapped in pretty html. On Apache in my localhost, it works, both > with Internet Explorer and Firefox. However, when I upload the script to a > remote server, it does not. A 500 Internal Server Error is displayed on the > browser. Check your server logs - they give more information on the cause of the error. > > The (simplified) piece of code is as follows: > > import webbrowser > webbrowser.open_new(http://www.google.com) try: webbrowser.open_new("http://www.google.com") instead. But the main problem is that you cannot make a web client open their browser. What your code does is make whichever computer is running the cgi code (i.e. the server) open a browser pointing to http://www.google.com. It works on your home machine, because you have a graphical interface running and python can open whatever browser it chooses. The code would work if it wasn't a cgi file (or requested by a web browser and executed by a python handler on the server in any way). Why not make the cgi file print the javascript that would make the client open another window? > > The server runs python 2.3. I am using python 2.5 in my localhost. The webbrowser module is present in python 2.3 but it is not what you want. You might also have other unrelated problems in the code. Use import cgitb; cgitb.enable() and check your server logs. Hope that helps, Cameron. -- http://mail.python.org/mailman/listinfo/python-list