Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Piet van Oostrum Newsgroups: comp.lang.python Subject: Re: Referrer key missing form os.environ dictionary? Date: Wed, 25 Sep 2013 15:59:56 -0400 Lines: 34 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: individual.net GK+H2PKC0vJOA6xyeGa2cQddxOMMKyg8hUFMDKrAIWFInsmaED Cancel-Lock: sha1:mf0jrD8jHeNvCq8oVH4FU1wcOxA= sha1:4iRs7PU390IsqlaDVwE9UdtKSgI= User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (darwin) Xref: csiph.com comp.lang.python:54755 Νίκος writes: > Στις 25/9/2013 5:01 μμ, ο/η Chris “Kwpolska” Warrick έγραψε: >> On Wed, Sep 25, 2013 at 2:45 PM, Νίκος 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 WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4]