I’d like to get the hostname in Google App Engine when running dev_appserver.py, because GAE is making a request of an external server and that server needs to know where to send its response.
Unfortunately, the canonical Python way doesn’t seem to work, being:
import socket
socket.gethostbyname(socket.gethostname())
The socket library doesn’t work in GAE.
Also,
os.environ['HTTP_HOST']
os.environ['SERVER_NAME']
Are both localhost.
How could one get the IP that an external server would connect to GAE?
Thanks for reading
the socket package might be disabled in the GAE sandbox.
Have you tried using the request object to determine this?
http://docs.webob.org/en/latest/reference.html#id1
might be the most reliable way.