Referrer key missing form os.environ dictionary?

Steven D'Aprano steve+comp.lang.python at pearwood.info
Wed Sep 25 10:52:45 EDT 2013


On Wed, 25 Sep 2013 17:04:55 +0300, Νίκος wrote:

> I would like to check for its existence and retrieve it if possible, if
> its not there then default to the string "UnKnown Ref".
> 
> I try to do this with:
> 
> referer = os.environ.get('HTTP_REFERER', 'UnknownRef')
> 
> but that doesn't return anything either.
> 
> Can you verify that its the correct way to grab the referral string?


The Referer is not an environment variable. How would your shell know 
what URL you were just browsing?

Have you googled for HTTP Referer? Do you understand what it is?


-- 
Steven



More information about the Python-list mailing list