473,398 Members | 2,427 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

webbrowser

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. 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.

The (simplified) piece of code is as follows:

import webbrowser
webbrowser.open_new(http://www.google.com)

The server runs python 2.3. I am using python 2.5 in my localhost.

Can anybody figure out why this may be happening?

Cheers,
Antonio
Nov 14 '07 #1
2 2551
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.
Nov 14 '07 #2
Dennis, Cameron,

You are absolutely right. I was not aware that the cgi was trying to open
the new browser on the server -I am a beginner with cgi, python and
javascript.

This simple javascript does the job perfectly:

window.open("http://www.google.com");

Thanks a lot,
Antonio
"Antonio Ceballos" <ac*******@gmail.comescribió en el mensaje
news:fh**********@hefestos.uned.es...
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. 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.

The (simplified) piece of code is as follows:

import webbrowser
webbrowser.open_new(http://www.google.com)

The server runs python 2.3. I am using python 2.5 in my localhost.

Can anybody figure out why this may be happening?

Cheers,
Antonio


Nov 15 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jim Hubbard | last post by:
How would I implement the IDispatch interface to handle the following in VB.Net <BEGIN> Controlling Download and Execution The WebBrowser Control gives you control over what it downloads,...
5
by: SPE - Stani's Python Editor | last post by:
Hi, During optimizing SPE for Ubuntu, I found something strange. I have Ubuntu 5.10 "The Breezy Badger" and unfortunately this code is not working: >>> import webbrowser >>>...
12
by: Alex Clark | last post by:
Greetings, (.NET 2.0, WinXP Pro/Server 2003, IE6 with latest service packs). I've decided to take advantage of the layout characteristics of HTML documents to simplify my printing tasks, but...
8
by: Prosperz | last post by:
Hi, I would like to make thumbnails of web page by capture content of a WebBrowser. By example, capture http://www.google.com. I used WebBrowser control with Framework 2.0. I try this : ...
8
by: Dustan | last post by:
At http://docs.python.org/whatsnew/modules.html on the webbrowser module, it says "A number of additional browsers were added to the supported list such as Firefox, Opera, Konqueror, and elinks." ...
11
by: Anil Gupte | last post by:
....and how do I insert one into my form? I used in VB 6.0 last, but cannot figure out where it is in .Net Thanx, -- Anil Gupte www.keeninc.net www.icinema.com
18
by: Zytan | last post by:
I have multiple threads writing to WebBrowser (using a function that checks InvokedRequired, and if so, invokes itself on the WebBrowser thread) and they are getting deadlocked. They only...
4
by: Gregory Bloom | last post by:
I'm running Python 2.5 under Windows. If I fire up IDLE and enter: it works like a champ, opening the page in Firefox. Same thing goes from a Windows cmd shell: it works as advertised. But...
11
by: kimiraikkonen | last post by:
Hi there, I needed to use MouseOver event on Webbrowser which is NOT provided by webbrowser control natively(what a disappointment), so i decided to go with another route to simulate this like: ...
3
by: TedTrippin | last post by:
Hi, Background - I've create a windows application in VS and added a WebBrowser component and all works well. I'm now trying to do this programmatically. My application now listens on a socket...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.