cgi script: get the url of this page
Matt Price
matt.price at utoronto.ca
Tue Aug 10 11:44:57 EDT 2004
On Tue, Aug 10, 2004 at 12:43:03AM +0200, Peter van Kampen wrote:
> > is there a standard trick to get the url of the current page in a cgi
>
> import os
>
> script = os.environ["SCRIPT_FILENAME"]
great, thanks for the hint. tho I think "script_filename" gives the
file name, not the internet url -- for that REQUEST_URI seems to be
better. This is great, thanks!
> > script, or the url from which form data has been passed?? I want to
>
> Hmm. You can try HTTP_REFERER but it depends on several things (browser,
> server, cgi-implementation etc.) wether this reports something useful or
> not. It is probably more reliably to check REMOTE_ADDR if that would provide
> enough information.
hmm, REMOTE_ADDR doesn't seem to show up mosto f the time;
HTTP_REFERRER works great, though, long as the fom isn't sent to the
page it came from...
thanks much!
matt
>
> Hth,
>
> PterK
>
-------------------------------------------
Matt Price matt.price at utoronto.ca
History Department, University of Toronto
(416) 978-2094
--------------------------------------------
More information about the Python-list
mailing list