CGI: how to get referer header?

Skip Montanaro skip at pobox.com
Sat Mar 22 18:15:16 EST 2003


    Skip> They should be available in the environment as HTTP_USER_AGENT and
    Skip> HTTP_REFERER.  Take a look at

    >> Thanks for the help. I tried using HTTP_USER_AGENT and HTTP_REFERER,
    >> but I get similar results, a tuple containing an empty dictionary.

Sorry, I should have given a specific example.  Try this:

    import os

    print "Referer:", os.environ.get("HTTP_REFERER", "<not present>")
    print "User Agent:", os.environ.get("HTTP_USER_AGENT", "<unknown>")

Skip





More information about the Python-list mailing list