def query_example(): print(request) if (request.method == 'POST'): # data = request.get_json(force=True) data = request.get_json() print('data is ' + format(data)) # print(type(data['value'])) utils.send_string(data['value']) return 'lion' else: return 'walrus'
def handle(self): print('Client connected') # self.request is the client connection while True: data = receive_string(self.request) print('Data retrieved : {0}'.format(data)) reply = pipe_command(data) if reply is None: print('Client disconnected') break send_string(self.request, reply) self.request.close()
def send_string(string): """Send a string to the arduino""" if utils.send_string(string): return {"success": True} return {"success": False}
def turn_off(): """Handle request to turn off an led""" if utils.send_string("off"): return {"success": True} return {"success": False}
def send_commands(self): while self.running: line = raw_input() send_string(self.socket, line)