473,815 Members | 3,341 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Python CGI & Webpage with an Image

Hi,

I have a set of CGI scripts set up and in one page (which is stored in
an HTML file then printed via a python CGI) there is an image. However
the image never displays, can anyone recommend a way round this
problem?

Kind regards,

rod
Mar 5 '08 #1
5 2047
Hello Rod,
I have a set of CGI scripts set up and in one page (which is stored in
an HTML file then printed via a python CGI) there is an image. However
the image never displays, can anyone recommend a way round this
problem?
We need more information, can you post a code snippet? error page? ...

My *guess* is that the web server don't know how to server the image
(wrong path configuration?)

HTH,
--
Miki <mi*********@gm ail.com>
http://pythonwise.blogspot.com

Mar 5 '08 #2
rodmc wrote:
[...]
Python:

f = open("finish.ht ml")
doc = f.read()
f.close()
print doc
You might need to start with:

print "Content-Type: text/html"
print

Is "finish.htm l" in the right place? When you browse to your
script, can you see that you're getting the html?
HTML:
[...]
<P><IMG SRC="banner.jpg " NAME="graphics1 " ALIGN=LEFT WIDTH=799
I suspect a server configuration and/or resource placement problem.
The image has a relative URL, and the user's browser will look for
it on the same path that it used to get the resource served by the
cgi script, up to last '/'.

Is banner.jpg in the right place, and is your web server configured
to treat everything in that directory as a cgi script, and thus
trying to execute the jpg? If one of those is the problem, just
move banner.jpg, and/or change the relative URL. For example,
SRC="../banner.jpg" will cause the browser to look for the jpg
one directory above.

Failing that, can look at the web server's log?

--
--Bryan
Mar 6 '08 #3
Hi,

Thanks for your very quick response. I have played around a bit more
so that both the image and HTML file are in the public_html folder.
They are called via python using a relative URL, and have permissions
set to 755. Within the HTML file the image is accessed using just
"banner.jpg ". The actual page displays ok except for the image - so it
has the same problem as before. However when the same page is
displayed without running through a CGI it displays perfectly.

Kind regards,

rod

On Mar 6, 11:46 am, Bryan Olson <fakeaddr...@no where.orgwrote:
rodmc wrote:

[...]
Python:
>
f = open("finish.ht ml")
doc = f.read()
f.close()
print doc

You might need to start with:

print "Content-Type: text/html"
print

Is "finish.htm l" in the right place? When you browse to your
script, can you see that you're getting the html?
HTML:
[...]
<P><IMG SRC="banner.jpg " NAME="graphics1 " ALIGN=LEFT WIDTH=799

I suspect a server configuration and/or resource placement problem.
The image has a relative URL, and the user's browser will look for
it on the same path that it used to get the resource served by the
cgi script, up to last '/'.

Is banner.jpg in the right place, and is your web server configured
to treat everything in that directory as a cgi script, and thus
trying to execute the jpg? If one of those is the problem, just
move banner.jpg, and/or change the relative URL. For example,
SRC="../banner.jpg" will cause the browser to look for the jpg
one directory above.

Failing that, can look at the web server's log?

--
--Bryan


Mar 6 '08 #4
rodmc wrote:
[...] I have played around a bit more
so that both the image and HTML file are in the public_html folder.
They are called via python using a relative URL, and have permissions
set to 755. Within the HTML file the image is accessed using just
"banner.jpg ". The actual page displays ok except for the image - so it
has the same problem as before. However when the same page is
displayed without running through a CGI it displays perfectly.
Is the cgi script in the same directory? The user's browser looks
for the jpg relative to the URL it used to get the page, which in
the case of the CGI script is the path to the script, not the
path to the html file.

If server logs are hard to get or read, try my runcgi.py script:

http://aspn.activestate.com/ASPN/Coo.../Recipe/550822
--
--Bryan
Mar 6 '08 #5
Is the cgi script in the same directory? The user's browser looks
for the jpg relative to the URL it used to get the page, which in
the case of the CGI script is the path to the script, not the
path to the html file.

No the CGI script is in a different folder, I could move everything to
the same folder I guess.

If server logs are hard to get or read, try my runcgi.py script:

http://aspn.activestate.com/ASPN/Coo.../Recipe/550822
Thanks, I will try this.

Rod
Mar 8 '08 #6

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

Similar topics

3
4376
by: Pekka Karjalainen | last post by:
How can I create image files and animations with Python? I will clarify a bit. This is a question of recreational programming. I have already made some animated gifs from Julia sets using Python and some external programs. I hit upon a quick solution of writing ppm image files (it's a simple text based format) and using ppmtogif to make gifs out of them, then using gifsicle (free program found on the web) to join them into animated gif...
0
4142
by: prakash | last post by:
Dear Friends I am new guy to Visual C++.NET I've program to save website as a image vc++.net . It have a function "SaveSnapshot" to save the webpage as an image On that function ifor saving as a image it uses image.Save method() This image.Save function have two overloaded form's first one is file name
0
259
by: Jason | last post by:
I have been trying to display pictures on my webpage on both imagebutton and image controls. I have tried adding the pictures at runtime (image1.imageURL = "pic.jpg") and setting the imageURL in the properties at desing time. When I look at the webpage on my computer, the picture displays just fine. When my clients look at the pictures it only shows part of the picture then stops and the page says done. With every refresh it shows a...
12
4248
by: M.L. | last post by:
When loaded from my hard drive, the webpage I'm working on renders fine on IE6, Firefox 2.0.0.1, and Opera 9.02. However, after uploading it to the web there are 2 images that fail to display on those browsers. All the other images and everything else on the page render just fine. 1.) I converted one of the gif images to a jpeg but that made no difference. 2.) I validated the webpage offline using Tagcheck, and online using the...
0
1632
by: =?Utf-8?B?Q2hha3JhdmFydGh5?= | last post by:
Hi, Have been trying to capture the webpage as image from quite a long time. Can some one suggest me a solution to convert or capture the HTML Output of any webresponse to anykind of image format. Have tried using the WebBrowser control to create a Bitmap object. WebBrowser control has "DrawToBitmap" method, which can help us to save the webpage to image format. But it is working with only http protocol, but not with HTTPS protocol.
3
11306
by: bush | last post by:
hi everyone! i want to get the ipaddress,and the country name of a webpage visitor,using asp.Net(C#).if anyone knows about it,plz rply me. thanx in advance.
3
6640
by: | last post by:
Hello, I try to open a new Window in code behind with : ClientScript.RegisterClientScriptBlock(this.GetType(), "MyOpenScript", "window.open('toto.doc');", true); My problem is that the new window is created but it disappears immediatly just after creation!! For information, I tried this:
0
1005
by: levi2713 | last post by:
We have IP cameras that we can view by putting the IP address in a web browser. This is a control panel type webpage, but I can go a step further and go to http://<ip address>/capture.html and it serves a webpage with snapshot of what the camera is viewing when the webpage is served. I want to save that particular image to a file. I looked at the html and got the image path, however if I go directly to that path, I get a file not found...
0
9736
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9611
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10408
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9226
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6897
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5710
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4359
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3888
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3030
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.