util.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:endpoints-python 作者: cloudendpoints 项目源码 文件源码
def get_app_hostname():
  """Return hostname of a running Endpoints service.

  Returns hostname of an running Endpoints API. It can be 1) "localhost:PORT"
  if running on development server, or 2) "app_id.appspot.com" if running on
  external app engine prod, or "app_id.googleplex.com" if running as Google
  first-party Endpoints API, or 4) None if not running on App Engine
  (e.g. Tornado Endpoints API).

  Returns:
    A string representing the hostname of the service.
  """
  if not is_running_on_app_engine() or is_running_on_localhost():
    return None

  app_id = app_identity.get_application_id()

  prefix = get_hostname_prefix()
  suffix = 'appspot.com'

  if ':' in app_id:
    tokens = app_id.split(':')
    api_name = tokens[1]
    if tokens[0] == 'google.com':
      suffix = 'googleplex.com'
  else:
    api_name = app_id

  return '{0}{1}.{2}'.format(prefix, api_name, suffix)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号