Antonio Ceballos wrote:

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
Check your server logs - they give more information on the cause of the
The (simplified) piece of code is as follows:

import webbrowser
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,


Search Discussions

Discussion Posts


Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 3 | next ›
Discussion Overview
grouppython-list @
postedNov 14, '07 at 1:05a
activeNov 15, '07 at 12:48a

2 users in discussion

Antonio Ceballos: 2 posts Cameron Walsh: 1 post



site design / logo © 2022 Grokbase