Example #1
0
def update_lights():
    if request.headers['Content-Type'] != 'application/json':
        print("ERROR: Content type is not JSON in HTTP header.")
    elif request.is_json:
        return SensorController.update_lights(request)
    else:
        print("ERROR: Request is not JSON.")
        return ('', 204)
Example #2
0
def update_lights():
    """
    POST => /lights
    Modifier la luminosité de chaque couleur de DEL

    Le POST peut être testé avec ce JSON:
    {"red": 128, "blue": 255, "white": 59}
    """
    if request.headers['Content-Type'] != 'application/json':
        print("ERROR: Content type is not JSON in HTTP header.")
    elif request.is_json:
        return SensorController.update_lights(request)
    else:
        print("ERROR: Request is not JSON.")
        return ('', 204)