How to determine the hostname a locally running appengine instance is assigned to?

803 Views Asked by At

I start an local instance of google app engine using this command line

/usr/local/google_appengine/dev_appserver.py --host localhost --host 0.0.0.0 --port 8080 --admin_port 8081 .

Is there any GAE API that can let me retrieve the hostname (argument to the --host parameter, in this case localhost) I have passed to this the dev_appserver.py?

1

There are 1 best solutions below

2
On BEST ANSWER

If you are using webapp2 on appengine you can access host property on the webapp2 request object.

class MyHandler(webapp2.RequestHandler):
    def get(self):
        host= self.request.host

https://webapp-improved.appspot.com/guide/request.html#common-request-attributes