Referrer key missing form os.environ dictionary?
Xaxa Urtiz
urtizvereaxaxa at gmail.com
Wed Sep 25 11:09:50 EDT 2013
Le mercredi 25 septembre 2013 17:02:45 UTC+2, Ferrous Cranus a écrit :
> Στις 25/9/2013 5:52 μμ, ο/η Steven D'Aprano έγραψε:
>
> > 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?
>
> >
>
> >
>
> Yes Steven googleign for 2 hours now.
>
>
>
> You were rigth about the carret it was a synatx error above which i
>
> missed and i was breakign my head to the wall to understand what was wot
>
> with the 'host' variable. why python doestn detect the exact synxtax
>
> error and ispoitnign to me to another line making me think the error is
>
> elsewhere?
>
>
>
> This indeed works now:
>
>
>
> ref = os.environ.get('HTTP_REFERER', 'Άγνωστο Ref')
>
>
>
> but iam wondering why this doesnt work also:
>
>
>
> ref = os.environ('HTTP_REFERER')
>
>
>
> Shouldnt both work?
http://www.tutorialspoint.com/python/dictionary_get.htm
More information about the Python-list
mailing list