コード例 #1
0
def hostname_get():
    """Determines the hostname of the machine.

    Returns:
        A JSON string with three keys when successful and two otherwise:
        success, error and hostname (if successful).

        success: true if successful.
        error: null if successful, str otherwise.
        hostname: str if successful.

        Example of success:
        {
            'success': true,
            'error': null,
            'hostname': 'tinypilot'
        }
        Example of error:
        {
            'success': false,
            'error': 'Cannot determine hostname.'
        }
    """
    try:
        return json_response.success2({'hostname': hostname.determine()})
    except hostname.Error as e:
        return json_response.error2(e), 500
コード例 #2
0
ファイル: api.py プロジェクト: tank0226/tinypilot
def hostname_get():
    """Determines the hostname of the machine.

    Returns:
        On success, a JSON data structure with the following properties:
        hostname: string.

        Example:
        {
            "hostname": "tinypilot"
        }

        Returns an error object on failure.
    """
    try:
        return json_response.success({'hostname': hostname.determine()})
    except hostname.Error as e:
        return json_response.error(e), 500
コード例 #3
0
def index_get():
    return flask.render_template(
        'index.html',
        hostname=hostname.determine(),
        custom_elements_files=find_files.custom_elements_files())
コード例 #4
0
def _page_title_prefix():
    if hostname.determine().lower() != _DEFAULT_HOSTNAME.lower():
        return '%s - ' % hostname.determine()
    return ''