How to get user-agent in Google App Engine using Python

User-Agent tells which is the client application that is making the request. It tells if it’s a browser (and information which browser it is), if it’s a robot (for example a Google/Yahoo/Bing spider), …  In theory the string is present in all HTTP headers, no matter which client is doing the request, but it might be ommited.

For knowing which is the browser the user is using, you should get the “User-Agent” string. For getting this string when programming in Python under Google App Engine you just have to include following line inside any  “get” or “post”  method which inherits from webapp.RequestHandler:


Another useful thing is to know the IP of the client who is making the request. This is even easier to do:


The IP can be used  to localize geographically (commonly geolocalize) to the one making the request.

Related links:

Trackback URL

, ,

Comments are closed.