def _set_context(): data = request.args context_str = data.get('context') context = {} for tok in context_str.split(','): k, v = tok.split('=') context[k.strip()] = v.strip() sid = data.get('session') ret, response = set_context(context, sid) return Response(json_encode({'ret': ret, 'response': response}), mimetype="application/json")