def send_event(self, etype: str, value: str = None) -> Response: v = "" if value is not None and value is not "": v = ',"value":"' + value + '"' edict = { "recipient": '{"type":"Peripheral","name":"LEDPanel-Top"}', "request": '{"type":"' + etype + '"' + v + "}", } event_viewer = viewers.EventViewer() message, status = event_viewer.create(edict) response = {"message": message} return Response(response, status=status)
def create(self, request: Request) -> Response: """Creates a new event.""" # Get parameters try: request_dict = request.data.dict() except Exception as e: message = "Unable to create request dict: {}".format(e) return Response(message, 400) # Get request parameters event_viewer = viewers.EventViewer() message, status = event_viewer.create(request_dict) response_dict = {"message": message} return Response(response_dict, status=status)
def create(self, request: Request) -> Response: """Creates a new event.""" # Get parameters try: if type(request.data) is dict: request_dict = request.data else: request_dict = request.data.dict() except Exception as e: message = "Unable to create request dict: {}".format(e) print(f'~~~Unable to create request dict, error: {e}') print(f'request.data: {request.data}') print(f'type: {type(request.data)}') return Response(message, 400) # Get request parameters event_viewer = viewers.EventViewer() message, status = event_viewer.create(request_dict) response_dict = {"message": message} return Response(response_dict, status=status)