Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #54755
| From | Piet van Oostrum <piet@vanoostrum.org> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Referrer key missing form os.environ dictionary? |
| Date | 2013-09-25 15:59 -0400 |
| Message-ID | <m2ioxoiseb.fsf@cochabamba.vanoostrum.org> (permalink) |
| References | <l1ulsv$4mv$1@dont-email.me> <mailman.315.1380117704.18130.python-list@python.org> <l1uqna$qi5$2@dont-email.me> |
Νίκος <nikos.gr33k@gmail.com> writes:
> Στις 25/9/2013 5:01 μμ, ο/η Chris “Kwpolska” Warrick έγραψε:
>> On Wed, Sep 25, 2013 at 2:45 PM, Νίκος <nikos.gr33k@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.
>>
> But one other problem appeared too:
>
> nikos@superhost.gr [~/www/cgi-bin]# python metrites.py
> File "metrites.py", line 27
> host = socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0] or
> UnKnown Host'
> ^
> SyntaxError: invalid syntax
>
>
> i dont see anything wrong with that line, and the carret is actually
> pointing to the "host".
There is an apostrophe (') missing before UnKnown.
host = socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0] or 'UnKnown Host'
--
Piet van Oostrum <piet@vanoostrum.org>
WWW: http://pietvanoostrum.com/
PGP key: [8DAE142BE17999C4]
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Referrer key missing form os.environ dictionary? Νίκος <nikos.gr33k@gmail.com> - 2013-09-25 15:45 +0300
Re: Referrer key missing form os.environ dictionary? Νίκος <nikos.gr33k@gmail.com> - 2013-09-25 16:14 +0300
Re: Referrer key missing form os.environ dictionary? Chris “Kwpolska” Warrick <kwpolska@gmail.com> - 2013-09-25 16:01 +0200
Re: Referrer key missing form os.environ dictionary? Νίκος <nikos.gr33k@gmail.com> - 2013-09-25 17:04 +0300
Re: Referrer key missing form os.environ dictionary? John Gordon <gordon@panix.com> - 2013-09-25 14:26 +0000
Re: Referrer key missing form os.environ dictionary? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-09-25 15:04 +0000
Re: Referrer key missing form os.environ dictionary? Νίκος <nikos.gr33k@gmail.com> - 2013-09-25 18:16 +0300
Re: Referrer key missing form os.environ dictionary? Tim Chase <python.list@tim.thechases.com> - 2013-09-25 10:42 -0500
Re: Referrer key missing form os.environ dictionary? Denis McMahon <denismfmcmahon@gmail.com> - 2013-09-25 21:17 +0000
Re: Referrer key missing form os.environ dictionary? Ned Batchelder <ned@nedbatchelder.com> - 2013-09-25 11:09 -0400
Re: Referrer key missing form os.environ dictionary? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-09-25 14:52 +0000
Re: Referrer key missing form os.environ dictionary? Νίκος <nikos.gr33k@gmail.com> - 2013-09-25 18:02 +0300
Re: Referrer key missing form os.environ dictionary? Xaxa Urtiz <urtizvereaxaxa@gmail.com> - 2013-09-25 08:09 -0700
Re: Referrer key missing form os.environ dictionary? Tim Chase <python.list@tim.thechases.com> - 2013-09-25 10:14 -0500
Re: Referrer key missing form os.environ dictionary? Νίκος <nikos.gr33k@gmail.com> - 2013-09-25 18:35 +0300
Re: Referrer key missing form os.environ dictionary? Grant Edwards <invalid@invalid.invalid> - 2013-09-25 15:18 +0000
Re: Referrer key missing form os.environ dictionary? Νίκος <nikos.gr33k@gmail.com> - 2013-09-25 18:41 +0300
Re: Referrer key missing form os.environ dictionary? John Gordon <gordon@panix.com> - 2013-09-25 16:27 +0000
Re: Referrer key missing form os.environ dictionary? Grant Edwards <invalid@invalid.invalid> - 2013-09-25 18:37 +0000
Re: Referrer key missing form os.environ dictionary? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-09-26 00:11 +0000
Re: Referrer key missing form os.environ dictionary? Terry Reedy <tjreedy@udel.edu> - 2013-09-25 21:32 -0400
Re: Referrer key missing form os.environ dictionary? Chris Angelico <rosuav@gmail.com> - 2013-09-26 13:25 +1000
Re: Referrer key missing form os.environ dictionary? Grant Edwards <invalid@invalid.invalid> - 2013-09-26 14:16 +0000
Re: Referrer key missing form os.environ dictionary? Robert Kern <robert.kern@gmail.com> - 2013-09-26 11:15 +0100
Re: Referrer key missing form os.environ dictionary? Grant Edwards <invalid@invalid.invalid> - 2013-09-26 14:11 +0000
Re: Referrer key missing form os.environ dictionary? Chris Angelico <rosuav@gmail.com> - 2013-09-27 01:17 +1000
Re: Referrer key missing form os.environ dictionary? Grant Edwards <invalid@invalid.invalid> - 2013-09-26 23:27 +0000
Re: Referrer key missing form os.environ dictionary? Chris Angelico <rosuav@gmail.com> - 2013-09-27 16:01 +1000
Re: Referrer key missing form os.environ dictionary? Νίκος <nikos.gr33k@gmail.com> - 2013-09-25 17:07 +0300
Re: Referrer key missing form os.environ dictionary? Robert Kern <robert.kern@gmail.com> - 2013-09-25 15:26 +0100
Re: Referrer key missing form os.environ dictionary? John Gordon <gordon@panix.com> - 2013-09-25 14:30 +0000
Re: Referrer key missing form os.environ dictionary? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-09-25 14:46 +0000
Re: Referrer key missing form os.environ dictionary? Piet van Oostrum <piet@vanoostrum.org> - 2013-09-25 15:59 -0400
Re: Referrer key missing form os.environ dictionary? John Gordon <gordon@panix.com> - 2013-09-25 14:18 +0000
Re: Referrer key missing form os.environ dictionary? Tim Chase <python.list@tim.thechases.com> - 2013-09-25 09:58 -0500
csiph-web