import requests


def system_check(uri, token):
    """Check DSA connection with the given host/token

    Args:
        uri (string): DSA host:port e.g. localhost:8080
        token (string): DSA token from /token/current HistomicsUI API

    Returns:
        int: 0 for successful connection, 1 otherwise
    """
    headers = {'Content-Type': 'application/json', 'Accept': 'application/json', 'Girder-Token': f'{token}'}
    request_url = f"http://{uri}/api/v1/system/check?mode=basic"
    response = requests.get(request_url, headers=headers)

    if response.status_code == 200:
        print("Successfully connected to DSA.")
        return 0
    else:
        print(f"Please check your host/token.")
        return 1