Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #37219

Re: Forcing Python to detect DocumentRoot

Date 2013-01-21 11:49 -0700
From Michael Torrie <torriem@gmail.com>
Subject Re: Forcing Python to detect DocumentRoot
References (3 earlier) <10ebf68d-12f9-46d6-be50-6c314500302d@googlegroups.com> <mailman.628.1358515700.2939.python-list@python.org> <2bf766db-ffcd-4a7f-8e08-6e3400618e78@googlegroups.com> <mailman.652.1358544847.2939.python-list@python.org> <ebe13670-42aa-4c3c-91da-a297a7b8e6e8@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.760.1358794195.2939.python-list@python.org> (permalink)

Show all headers | View raw


On 01/19/2013 01:01 AM, Ferrous Cranus wrote:
> # render html template and print it data = f.read() counter =
> '''<center> <a href="mailto:support@superhost.gr"> <img
> src="/data/images/mail.png"> </a>
> 
> <table border=2 cellpadding=2 bgcolor=black> <td><font color=lime>
> Αριθμός Επισκεπτών </td> <td><font color=cyan> %d </td>''' % hits[0] 
> ========================================
> 
> While from within the same counter.py file
> 
> # open html template file f = open(
> '/home/nikos/public_html/test.txt' )
> 
> opens OK the page file which is also past addons domain's document
> root
> 
> Can you help counter.py to load the image? Why does it fail to load
> it? Python can have access to ANY filesystempath , no matter from
> what folder counter.py script runs from. Correct?

No I can't because counter.py doesn't "load the image."  The browser
does.  If the image fails to load it is because the apache web server
cannot find it.  In other words your image src url is bad.  It has
nothing to do with python.  Python is only spitting out html code.
That's it.  Image loading is done by apache on behalf of a request from
the web browser.  Since the url is a direct url to a file, there is no
CGI that runs.

I understand that you have a difficulty understanding the relationship
between the browser, the web server, and the cgi script.  The process
goes like this:

- browser requests the url, which happens to be the CGI script, counter.py.
- web server runs counter.py returns html code to the browser.
- browser parses html code, renders it, and requests any images that the
html code references.
- Web server tries to locate the image based on its own rules and
config, and serves it if possible, otherwise, returns error 404.

So you simply have the image url wrong.  apache is not mapping /data to
where you think it is.  You have to either fix this in apache's configs,
or determine where the image really is in apache's url space, and change
the cgi to output the correct html.  Your problem isn't a python one at
all; it's an apache problem.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Forcing Python to detect DocumentRoot Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-16 05:51 -0800
  Re: Forcing Python to detect DocumentRoot Joel Goldstick <joel.goldstick@gmail.com> - 2013-01-16 09:01 -0500
    Re: Forcing Python to detect DocumentRoot Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-16 06:32 -0800
      Re: Forcing Python to detect DocumentRoot Joel Goldstick <joel.goldstick@gmail.com> - 2013-01-16 09:39 -0500
    Re: Forcing Python to detect DocumentRoot Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-16 06:32 -0800
  Re: Forcing Python to detect DocumentRoot Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-17 01:03 -0800
  Re: Forcing Python to detect DocumentRoot rusi <rustompmody@gmail.com> - 2013-01-17 05:51 -0800
  Re: Forcing Python to detect DocumentRoot Roy Smith <roy@panix.com> - 2013-01-17 09:09 -0500
    Re: Forcing Python to detect DocumentRoot Joel Goldstick <joel.goldstick@gmail.com> - 2013-01-17 10:14 -0500
      Re: Forcing Python to detect DocumentRoot Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-18 05:02 -0800
        Re: Forcing Python to detect DocumentRoot Joel Goldstick <joel.goldstick@gmail.com> - 2013-01-18 08:28 -0500
          Re: Forcing Python to detect DocumentRoot Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-18 10:58 -0800
            Re: Forcing Python to detect DocumentRoot Joel Goldstick <joel.goldstick@gmail.com> - 2013-01-18 14:11 -0500
            Re: Forcing Python to detect DocumentRoot Chris Angelico <rosuav@gmail.com> - 2013-01-19 08:34 +1100
              Re: Forcing Python to detect DocumentRoot Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-19 00:01 -0800
                Re: Forcing Python to detect DocumentRoot Michael Torrie <torriem@gmail.com> - 2013-01-21 11:49 -0700
              Re: Forcing Python to detect DocumentRoot Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-19 00:01 -0800
                Re: Forcing Python to detect DocumentRoot Piet van Oostrum <piet@vanoostrum.org> - 2013-01-19 21:01 +0100
                Re: Forcing Python to detect DocumentRoot Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-20 22:25 -0800
                Re: Forcing Python to detect DocumentRoot Dave Angel <d@davea.name> - 2013-01-21 07:33 -0500
                Re: Forcing Python to detect DocumentRoot Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-21 06:55 -0800
                Re: Forcing Python to detect DocumentRoot Michael Torrie <torriem@gmail.com> - 2013-01-21 11:42 -0700
                Re: Forcing Python to detect DocumentRoot Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-21 06:55 -0800
          Re: Forcing Python to detect DocumentRoot Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-18 10:58 -0800
        Re: Forcing Python to detect DocumentRoot Rodrick Brown <rodrick.brown@gmail.com> - 2013-01-18 08:41 -0500
          Re: Forcing Python to detect DocumentRoot Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-18 12:49 -0800
          Re: Forcing Python to detect DocumentRoot Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-18 12:49 -0800
        Re: Forcing Python to detect DocumentRoot Michael Torrie <torriem@gmail.com> - 2013-01-21 08:46 -0700
          Re: Forcing Python to detect DocumentRoot Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-21 08:02 -0800
            Re: Forcing Python to detect DocumentRoot Michael Torrie <torriem@gmail.com> - 2013-01-21 11:36 -0700
          Re: Forcing Python to detect DocumentRoot Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-21 08:02 -0800
            Re: Forcing Python to detect DocumentRoot Piet van Oostrum <piet@vanoostrum.org> - 2013-01-21 20:05 +0100
      Re: Forcing Python to detect DocumentRoot Ferrous Cranus <nikos.gr33k@gmail.com> - 2013-01-18 05:02 -0800
  Re: Forcing Python to detect DocumentRoot Barry Scott <barry@barrys-emacs.org> - 2013-01-19 11:40 +0000
  Re: Forcing Python to detect DocumentRoot alex23 <wuwei23@gmail.com> - 2013-01-19 17:53 -0800

csiph-web