def _api_state_complete(self, event, context): stream, request, query, t = context indent, mimetype = None, "application/json" dictionary = cgi.parse_qs(query) if "debug" in dictionary and utils.intify(dictionary["debug"][0]): indent, mimetype = 4, "text/plain" dictionary = STATE.dictionarize() octets = json.dumps(dictionary, indent=indent) stringio = StringIO.StringIO(octets) response = Message() response.compose(code="200", reason="Ok", body=stringio, mimetype=mimetype) stream.send_response(request, response)
def _api_state_complete(event, context): ''' Callback invoked when the /api/state has changed ''' stream, request, query, otime = context indent, mimetype = None, "application/json" dictionary = cgi.parse_qs(query) if "debug" in dictionary and utils.intify(dictionary["debug"][0]): indent, mimetype = 4, "text/plain" dictionary = STATE.dictionarize() octets = json.dumps(dictionary, indent=indent) response = Message() response.compose(code="200", reason="Ok", body=octets, mimetype=mimetype) stream.send_response(request, response)