Embarassingly Dumb HTML Question

Talk about computers, hardware, applications, and consumer electronics.
User avatar
Retrofuturist
Posts: 3131
Joined: 2008.09.19 (06:55)
MBTI Type: ENTP
Location: California, USA
Contact:

Postby t̷s͢uk̕a͡t͜ư » 2008.10.07 (01:19)

I have an image. It's in /var/www/img/, and it's called fox_dog.png.
I have an Apache2 server running out of /var/www.
The following HTML code loads it perfectly:

Code: Select all

<img src="img/fox_dog.png">
Can anyone -- anyone at all -- tell me why the above code, when generated through a Python CGI script using Apache2's mod_python module, consistently fails to load that same picture?
The only difference is that it's being generated by the script, which shouldn't actually even matter because the script doesn't process the HTML in the slightest, and merely returns it as a string to the Apache2 server, which should then process it in exactly the same way as the quick test HTML file.

Things to note:
Everyone and their grandmothers have write permissions to /var/www and /var/www/img. I've been easily able to create, destroy, and manipulate content in these directories without a hitch.
While it has been discovered that the prime working directory that the CGI script uses is just root ( '/', without the 'var/www' part), just in case that matters in the slightest for some reason once the HTML is generated and processed by Apache2, the following variations have also failed:

Code: Select all

<img src="/var/www/img/fox_dog.png">
<img src="var/www/img/fox_dog.png">
Even when changing the current working directory within the CGI script to /var/www, the following variations have failed:

Code: Select all

<img src="img/fox_dog.png">
<img src="./img/fox_dog.png">
<img src="/var/www/img/fox_dog.png">
This is driving me insane, and it's so, so ridiculously simple an issue...
[spoiler="you know i always joked that it would be scary as hell to run into DMX in a dark ally, but secretly when i say 'DMX' i really mean 'Tsukatu'." -kai]"... and when i say 'scary as hell' i really mean 'tight pink shirt'." -kai[/spoiler][/i]
spoiler

Image


User avatar
Vampire Salesman
Posts: 112
Joined: 2008.10.02 (01:51)
NUMA Profile: http://nmaps.net/user/

Postby xeronix » 2008.10.07 (01:27)

might it be the directory that the picture is in doesnt correspond with the coding?
Image
Image

User avatar
The Konami Number
Posts: 586
Joined: 2008.09.19 (12:27)
NUMA Profile: http://nmaps.net/user/Atilla

Postby Atilla » 2008.10.07 (02:45)

I'm assuming you've used this for other images and it works? (i.e. it's not that the quotation marks or other odd characters in the output are somehow screwing up your Python.)

User avatar
Lifer
Posts: 1099
Joined: 2008.09.26 (21:35)
NUMA Profile: http://nmaps.net/user/smartalco
MBTI Type: INTJ

Postby smartalco » 2008.10.07 (04:15)

I believe you need "/img/fox_dog.png"

without the first slash the path is relative, with it, the path is from the web root in Apache
Image
Tycho: "I don't know why people ever, ever try to stop nerds from doing things. It's really the most incredible waste of time."
Adam Savage: "I reject your reality and substitute my own!"

User avatar
Global Mod
Global Mod
Posts: 1416
Joined: 2008.09.26 (05:35)
NUMA Profile: http://nmaps.net/user/scythe33
MBTI Type: ENTP
Location: 09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0

Postby scythe » 2008.10.08 (08:52)

Add an alt="STRING" to it, to see if Python is passing the code correctly.
i.e. <img src="img/fox_dog.png" alt="I go chop your dollar">
As soon as we wish to be happier, we are no longer happy.

User avatar
Semimember
Posts: 15
Joined: 2008.09.23 (18:10)
NUMA Profile: http://nmaps.net/user/AlliedEnvy
Location: Houston, TX

Postby AlliedEnvy » 2008.10.08 (16:07)

Just to make sure we're on the same page, you've checked the source of the page generated by your code, and the source contains exactly

Code: Select all

<img src="img/fox_dog.png">
?
      __
     /\ \   _ _ _          _ ______
    /  \ \ | | (_)        | |  ____|
   / /\ \ \| | |_  ___  __| | |__   _ ____   ___   _
  / / /\ \ \ | | |/ _ \/ _` |  __| | '_ \ \ / / | | |
 / / /__\_\ \| | |  __/ (_| | |____| | | | V /| |_| |
/ / /________\_|_|\___|\__,_|______|_| |_|\_/  \__, |
\/___________/ Any sufficiently advanced kludge __/ |
     is indistinguishable from careful design. |___/

User avatar
Retrofuturist
Posts: 3131
Joined: 2008.09.19 (06:55)
MBTI Type: ENTP
Location: California, USA
Contact:

Postby t̷s͢uk̕a͡t͜ư » 2008.10.08 (17:31)

Just for the record, I'm not leaving this thread hanging or anything - the server running all this is at my place of employ and some moron decided it'd be a good idea to turn it off. I'll have more to say when I'm at work again.
xeronix wrote:might it be the directory that the picture is in doesnt correspond with the coding?
No, it's there alright. I can open that image (via copy-pasting the src string) in an image viewer, and as I said, everyone and their grandmother has read and write permissions to it.
Besides which, the test page I wrote works absolutely fine:

Code: Select all

<html><head/><body><img src="img/fox_dog.png"></body></html>
That loads the image perfectly.
scythe wrote:Add an alt="STRING" to it, to see if Python is passing the code correctly.
i.e. <img src="img/fox_dog.png" alt="I go chop your dollar">
Already did. The alt text loads instead of the image every time.
smartalco wrote:I believe you need "/img/fox_dog.png"

without the first slash the path is relative, with it, the path is from the web root in Apache
I can't believe I didn't think of this.
Thanks. I'll try it.
Atilla wrote:I'm assuming you've used this for other images and it works? (i.e. it's not that the quotation marks or other odd characters in the output are somehow screwing up your Python.)
The Python script is returning syntactically correct HTML, but in fact, no images I try to load will work if it's the Python script that's generating the HTML.
AE wrote:Just to make sure we're on the same page, you've checked the source of the page generated by your code, and the source contains exactly

Code: Select all

<img src="img/fox_dog.png">
?
Yes. Exactly that.

The generated source is something like:

Code: Select all

<html><head><title>my title</title></head><body>
Blah blah: <input ...><br>
Blah blah blah: <input ...><br>
Blah:<br><textarea ...><br><br>
Image:<br>
<img src="img/fox_dog.png">
</body></html>
It really is just that simple. I'm not doing anything fancy whatsoever.
[spoiler="you know i always joked that it would be scary as hell to run into DMX in a dark ally, but secretly when i say 'DMX' i really mean 'Tsukatu'." -kai]"... and when i say 'scary as hell' i really mean 'tight pink shirt'." -kai[/spoiler][/i]
spoiler

Image


User avatar
Semimember
Posts: 15
Joined: 2008.09.23 (18:10)
NUMA Profile: http://nmaps.net/user/AlliedEnvy
Location: Houston, TX

Postby AlliedEnvy » 2008.10.08 (18:13)

Well, I dunno. You say it's generating syntactically correct HTML. Have you run it through a verifier? Also, it might be a good idea to look at the error console and other dev tools that come with your browser. It's hard for me to believe that the problem is due how your source is being generated, and a lot more likely (to me) that the generated source itself has an error in some way.
      __
     /\ \   _ _ _          _ ______
    /  \ \ | | (_)        | |  ____|
   / /\ \ \| | |_  ___  __| | |__   _ ____   ___   _
  / / /\ \ \ | | |/ _ \/ _` |  __| | '_ \ \ / / | | |
 / / /__\_\ \| | |  __/ (_| | |____| | | | V /| |_| |
/ / /________\_|_|\___|\__,_|______|_| |_|\_/  \__, |
\/___________/ Any sufficiently advanced kludge __/ |
     is indistinguishable from careful design. |___/

User avatar
Retrofuturist
Posts: 3131
Joined: 2008.09.19 (06:55)
MBTI Type: ENTP
Location: California, USA
Contact:

Postby t̷s͢uk̕a͡t͜ư » 2008.10.08 (19:49)

AlliedEnvy wrote:Well, I dunno. You say it's generating syntactically correct HTML. Have you run it through a verifier? Also, it might be a good idea to look at the error console and other dev tools that come with your browser. It's hard for me to believe that the problem is due how your source is being generated, and a lot more likely (to me) that the generated source itself has an error in some way.
I can tell that it's syntactically correct because I can view the generated source through my browser as though it was any other HTML file. I mean, the page loads just fine - it just can't find the image.
...the problem was that I wasn't giving the path correctly:
smartalco wrote:I believe you need "/img/fox_dog.png"

without the first slash the path is relative, with it, the path is from the web root in Apache
That did the trick. I can't believe that escaped me.
Thanks.
[spoiler="you know i always joked that it would be scary as hell to run into DMX in a dark ally, but secretly when i say 'DMX' i really mean 'Tsukatu'." -kai]"... and when i say 'scary as hell' i really mean 'tight pink shirt'." -kai[/spoiler][/i]
spoiler

Image


User avatar
Lifer
Posts: 1099
Joined: 2008.09.26 (21:35)
NUMA Profile: http://nmaps.net/user/smartalco
MBTI Type: INTJ

Postby smartalco » 2008.10.10 (02:31)

I am the master at answering embarrassingly easy HTML questions (or you can take out either one of those conditions, I can answer embarrassingly easy general questions or very specific HTML questions as well)
Image
Tycho: "I don't know why people ever, ever try to stop nerds from doing things. It's really the most incredible waste of time."
Adam Savage: "I reject your reality and substitute my own!"


Who is online

Users browsing this forum: No registered users and 2 guests