From d492525bd37d36b33a4f745691ee3aadc6c4a4b6 Mon Sep 17 00:00:00 2001 From: waltem01 Date: Thu, 23 Nov 2023 10:46:43 +0100 Subject: [PATCH] set color endpoint --- API/main.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/API/main.py b/API/main.py index eee855d..4690754 100644 --- a/API/main.py +++ b/API/main.py @@ -44,6 +44,24 @@ def set_pixel(): return jsonify(response) +@api.route('/color', methods=['POST']) +def set_color(): + response = { 'success': True } + try: + global matrix + + data = request.get_json() + red = data.get('r') + green = data.get('g') + blue = data.get('b') + + matrix.set_color(red, green, blue) + except Exception as e: + print(e) + response['success'] = False + + return jsonify(response) + @api.route('/update', methods=['GET']) def update_matrix(): response = { 'success': True }