I have an App Engine application that has multiple independent modules.
When deployed, these modules become available at http://<module>.<app_id>.appspot.com
, and when testing locally with dev_appserver.py mod1.yaml mod2.yaml --port-9000
, then mod1
runs in http://localhost:9000
and mod2
runs in http://localhost:9001
. All the modules are running on the same project. So far so good.
Let's assume mod1
needs to talk to mod2
. Is there a way I can get a url for mod2
within mod1
, dynamically?
# In mod1's code
import google.some.magic
url_for_mod2 = magic.get_url_for_module('mod2') # http://localhost:9001 or http://mod2.id.appspot.com
It is possible to build cross-module urls that work on both GAE and on the development server using the modules.get_hostname()
API. You can find an example in this answer: https://stackoverflow.com/a/31145647/4495081