Ejemplo n.º 1
0
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'
Ejemplo n.º 2
0
 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()
Ejemplo n.º 3
0
def send_string(string):
    """Send a string to the arduino"""
    if utils.send_string(string):
        return {"success": True}
    return {"success": False}
Ejemplo n.º 4
0
def turn_off():
    """Handle request to turn off an led"""
    if utils.send_string("off"):
        return {"success": True}
    return {"success": False}
Ejemplo n.º 5
0
 def send_commands(self):
     while self.running:
         line = raw_input()
         send_string(self.socket, line)