Get the browser’s user agent with mod_python

August 7th, 2009

I recently discovered the beauty of mod_python and python server pages (psp), and I’ve been slowly replacing the php code on my server as I make changes. One thing that took me awhile to figure out was how to get the user-agent of the requesting client. In the hopes of helping others in the same boat, here’s the line of code:

<%= req.headers_in['User-Agent']  %>


As you can see all the request’s header information is in the req.header_in dictionary.

Comments

  1. nicolas314
    August 18th, 2009 at 00:28 | #1

    Thanks for publishing this! You just saved me an hour of digging through mod_python documentation. Cheers!

Comments are closed.