mirror of
https://gitlab1.ptb.de/waltem01/Matrix
synced 2024-12-25 11:31:46 +00:00
enabled CORS on api server
This commit is contained in:
parent
903b946922
commit
18c9546c70
9
API/main.py
Normal file → Executable file
9
API/main.py
Normal file → Executable file
@ -3,13 +3,16 @@ from deps.samplebase import SampleBase
|
|||||||
from rgbmatrix import graphics
|
from rgbmatrix import graphics
|
||||||
|
|
||||||
from flask import Flask, request, jsonify
|
from flask import Flask, request, jsonify
|
||||||
|
from flask_cors import CORS, cross_origin
|
||||||
from waitress import serve
|
from waitress import serve
|
||||||
import time, threading
|
import time, threading
|
||||||
|
|
||||||
|
|
||||||
api = Flask(__name__)
|
api = Flask(__name__)
|
||||||
|
cors = CORS(api)
|
||||||
|
|
||||||
@api.route('/text', methods=['POST'])
|
@api.route('/text', methods=['POST'])
|
||||||
|
@cross_origin()
|
||||||
def display_text():
|
def display_text():
|
||||||
# prepare response data
|
# prepare response data
|
||||||
response = { 'success': True }
|
response = { 'success': True }
|
||||||
@ -34,6 +37,7 @@ def display_text():
|
|||||||
return jsonify(response)
|
return jsonify(response)
|
||||||
|
|
||||||
@api.route('/pixel', methods=['POST'])
|
@api.route('/pixel', methods=['POST'])
|
||||||
|
@cross_origin()
|
||||||
def set_pixel():
|
def set_pixel():
|
||||||
# prepare response data
|
# prepare response data
|
||||||
response = { 'success': True }
|
response = { 'success': True }
|
||||||
@ -57,6 +61,7 @@ def set_pixel():
|
|||||||
return jsonify(response)
|
return jsonify(response)
|
||||||
|
|
||||||
@api.route('/circle', methods=['POST'])
|
@api.route('/circle', methods=['POST'])
|
||||||
|
@cross_origin()
|
||||||
def draw_circle():
|
def draw_circle():
|
||||||
# prepare response data
|
# prepare response data
|
||||||
response = { 'success': True }
|
response = { 'success': True }
|
||||||
@ -81,6 +86,7 @@ def draw_circle():
|
|||||||
return jsonify(response)
|
return jsonify(response)
|
||||||
|
|
||||||
@api.route('/rectangle', methods=['POST'])
|
@api.route('/rectangle', methods=['POST'])
|
||||||
|
@cross_origin()
|
||||||
def draw_rectangle():
|
def draw_rectangle():
|
||||||
# prepare response data
|
# prepare response data
|
||||||
response = { 'success': True }
|
response = { 'success': True }
|
||||||
@ -107,6 +113,7 @@ def draw_rectangle():
|
|||||||
return jsonify(response)
|
return jsonify(response)
|
||||||
|
|
||||||
@api.route('/color', methods=['POST'])
|
@api.route('/color', methods=['POST'])
|
||||||
|
@cross_origin()
|
||||||
def set_color():
|
def set_color():
|
||||||
# prepare response data
|
# prepare response data
|
||||||
response = { 'success': True }
|
response = { 'success': True }
|
||||||
@ -131,6 +138,7 @@ def set_color():
|
|||||||
return jsonify(response)
|
return jsonify(response)
|
||||||
|
|
||||||
@api.route('/clear', methods=['GET'])
|
@api.route('/clear', methods=['GET'])
|
||||||
|
@cross_origin()
|
||||||
def clear_canvas():
|
def clear_canvas():
|
||||||
# prepare response data
|
# prepare response data
|
||||||
response = { 'success': True }
|
response = { 'success': True }
|
||||||
@ -147,6 +155,7 @@ def clear_canvas():
|
|||||||
return jsonify(response)
|
return jsonify(response)
|
||||||
|
|
||||||
@api.route('/update', methods=['GET'])
|
@api.route('/update', methods=['GET'])
|
||||||
|
@cross_origin()
|
||||||
def update_matrix():
|
def update_matrix():
|
||||||
response = { 'success': True }
|
response = { 'success': True }
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user