<filename>examples/communication/dcd_hub.py
import requests

def dcd_hub_status():
    """
    Return the DCD Hub status:
    - 0: Connection successful
    - 1: Could not reach the hub (Connection or Hub issue)
    """

    uri = "https://dwd.tudelft.nl/api/health"
    try:
        json_result = requests.get(uri).json()
        if json_result["status"] is 0:
            # We received a response with status = 0, everything is fine
            return 0
        # In any other case, there is a issue
        return 1
    except Exception as e:
        # Show some information about the error
        print(str(e))
        # Return 1, the connection wasn't successful
        return 1

print("DCD Hub Status: " + str(dcd_hub_status()))

<filename>examples/communication/dcd_hub.py
import requests

def dcd_hub_status():
    """
    Return the DCD Hub status:
    - 0: Connection successful
    - 1: Could not reach the hub (Connection or Hub issue)
    """

    uri = "https://dwd.tudelft.nl/api/health"
    try:
        json_result = requests.get(uri).json()
        if json_result["status"] is 0:
            # We received a response with status = 0, everything is fine
            return 0
        # In any other case, there is a issue
        return 1
    except Exception as e:
        # Show some information about the error
        print(str(e))
        # Return 1, the connection wasn't successful
        return 1

print("DCD Hub Status: " + str(dcd_hub_status()))

Return the DCD Hub status:     - 0: Connection successful     - 1: Could not reach the hub (Connection or Hub issue) # We received a response with status = 0, everything is fine # In any other case, there is a issue # Show some information about the error # Return 1, the connection wasn't successful