def get_app_hostname():
if not is_running_on_app_engine() or is_running_on_localhost():<EOL><INDENT>return None<EOL><DEDENT>app_id = app_identity.get_application_id()<EOL>prefix = get_hostname_prefix()<EOL>suffix = '<STR_LIT>'<EOL>if '<STR_LIT::>' in app_id:<EOL><INDENT>tokens = app_id.split('<STR_LIT::>')<EOL>api_name = tokens[<NUM_LIT:1>]<EOL>if tokens[<NUM_LIT:0>] == '<STR_LIT>':<EOL><INDENT>suffix = '<STR_LIT>'<EOL><DEDENT><DEDENT>else:<EOL><INDENT>api_name = app_id<EOL><DEDENT>return '<STR_LIT>'.format(prefix, api_name, suffix)<EOL>
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.