0

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.

arik
  • 71
  • 1
  • 3

1 Answers1

1

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.
  • 85,731
  • 25
  • 98
  • 139