mirror of
https://gitlab1.ptb.de/waltem01/Matrix
synced 2024-11-12 16:03:50 +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 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:
|
||||
|
Loading…
Reference in New Issue
Block a user