def disable(): socket = request.args.get('value') if socket == 'all': for socket in range(1, 9): relay_ctl.turnoff(str(socket)) state = relay_ctl.state() return json.dumps(state) elif socket in validSocket[:-1]: relay_ctl.turnoff(socket) state = relay_ctl.state() return json.dumps(state) else: print "Invalid Request: invalid socket, valid sockets: " + ' '.join( validSocket) return json.dumps({"error": "invalid socket"})
def state(): socket = request.args.get('value') state = relay_ctl.state() if socket == 'all' or socket == None: return json.dumps(state) elif socket in validSocket[:-1]: return json.dumps({socket: state[socket]}) else: print "Invalid Request: invalid socket, valid sockets: " + ' '.join( validSocket) return json.dumps({"error": "invalid socket"})
def reset(): relay_ctl.reset() state = relay_ctl.state() return json.dumps(state)