Στις 25/9/2013 5:01 μμ, ο/η Chris “Kwpolska” Warrick έγραψε:
On Wed, Sep 25, 2013 at 2:45 PM, Νίκος <nikos.gr...@gmail.com> wrote:
Hello, i decided am ong other os.environ variables to also grab the
'HTTP_REFERER' fiel but when i try to run my script i was seeing a KeyError
complaining that 'HTTP_REFERER' didnt exist.
So, to see what existed in the os.environ dictionary i issues a print(
os.environ ) to see all available keys and their values:
The Referer header is not mandatory by any means. Your client
probably does not send it.
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?
--
https://mail.python.org/mailman/listinfo/python-list