def put_light(id): """ Setze den Status einer Lampe :body name (optional): Name der Lampe :body r (optional): Rotwert [0...255] :body g (optional): Grünwert [0...255] :body b (optional): Blauwert [0...255] """ json = request.get_json() if not json: return jsonify({'message': 'no data received'}), 200 light = Light.get(id) if not light: return jsonify({'message': 'Light not found'}), 404 if json.get('name') is not None: light.name = json.get('name') if json.get('r') is not None: light.r = json.get('r') if json.get('g') is not None: light.g = json.get('g') if json.get('b') is not None: light.b = json.get('b') light.save() return jsonify({'message': 'Light saved'}), 200
def delete_light(id): """ Lösche eine Lampe """ light = Light.get(id) if not light: return jsonify({'message': 'Light not found'}), 404 light.delete() return jsonify({'message': 'Light deleted'}), 200