예제 #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 ''