views:

39

answers:

2

hi, i wanted to know in python how can i get the host the user came from? how do i extract it?

i tried this:

host = self.request._environ['HTTP_HOST']

but it's empty...

Do you have any idea what it should be

Thanks.

+1  A: 

self.request._environ['HTTP_HOST'] tells you your host name.

You can use self.request.remote_addr to get the remote IP address. You'll need to do a reverse DNS lookup (which might fail) if you need a host name from that.

Chris B.
I want my hostname i want to search for a word in my host name... but it's empty
arik
if i am only in local host it will work? it will be my hostname?
arik
A: 

Did you try REMOTE_ADDR?

jtp