diff --git a/API/main.py b/API/main.py old mode 100644 new mode 100755 index 959145f..b3d1be7 --- a/API/main.py +++ b/API/main.py @@ -3,13 +3,16 @@ from deps.samplebase import SampleBase from rgbmatrix import graphics from flask import Flask, request, jsonify +from flask_cors import CORS, cross_origin from waitress import serve import time, threading api = Flask(__name__) +cors = CORS(api) @api.route('/text', methods=['POST']) +@cross_origin() def display_text(): # prepare response data response = { 'success': True } @@ -34,6 +37,7 @@ def display_text(): return jsonify(response) @api.route('/pixel', methods=['POST']) +@cross_origin() def set_pixel(): # prepare response data response = { 'success': True } @@ -57,6 +61,7 @@ def set_pixel(): return jsonify(response) @api.route('/circle', methods=['POST']) +@cross_origin() def draw_circle(): # prepare response data response = { 'success': True } @@ -81,6 +86,7 @@ def draw_circle(): return jsonify(response) @api.route('/rectangle', methods=['POST']) +@cross_origin() def draw_rectangle(): # prepare response data response = { 'success': True } @@ -107,6 +113,7 @@ def draw_rectangle(): return jsonify(response) @api.route('/color', methods=['POST']) +@cross_origin() def set_color(): # prepare response data response = { 'success': True } @@ -131,6 +138,7 @@ def set_color(): return jsonify(response) @api.route('/clear', methods=['GET']) +@cross_origin() def clear_canvas(): # prepare response data response = { 'success': True } @@ -147,6 +155,7 @@ def clear_canvas(): return jsonify(response) @api.route('/update', methods=['GET']) +@cross_origin() def update_matrix(): response = { 'success': True } try: