def dataGraph(): if request.method == 'POST': requestdata = request.get_json() node = requestdata['node'] link = requestdata['link'] count = int(requestdata['num']) envfilter = requestdata['ENVIRONMENT'] if 'ENVIRONMENT' in requestdata else [] session_id = requestdata['DSID'] if 'DSID' in requestdata else None else: node = request.args.get('node') link = request.args.get('link') count = int(request.args.get('num')) envfilter = [] session_id = None if not 0<=count<len(user_data): response = jsonify({}) response.status_code = 404 return response link_type = clickparser.countwt # count is 0 when client requests for all sessions if count!=0 or session_id!=None: click_graph = clickparser.make_nodes(user_data[session_id]) if session_id!=None else clickparser.session_fetch(user_data, count, envfilter) l = clickparser.make_links(click_graph["nodes"], node, link_type) response_data = clickparser.jsonify_data(l[0], l[1]) clickparser.converge_rvid_nodes(response_data) response = jsonify(response_data) response.status_code = 200 return response else: all_response = jsonify(all_response_data) all_response.status_code = 200 return all_response
f=open("../st9_sept29.csv", "rb") lines = [] with f as csvfile: linereader = csv.DictReader(csvfile, dialect='excel') for row in linereader: lines.append(row) user_data = clickparser.parse(lines) all_sessions_data = clickparser.all_sessions(user_data) node = "COMPONENT_TYPE" link_type = clickparser.countwt all_links = clickparser.make_links(all_sessions_data["nodes"], node, link_type) all_response_data = clickparser.jsonify_data(all_links[0], all_links[1]) clickparser.converge_rvid_nodes(all_response_data) NAMES=["abc","abcd","abcde","abcdef"] @app.route('/searchdsid',methods=['GET', 'POST']) def searchdsid(): def f(x): print x, user_data[x] return search in x and user_data[x][0]['ENVIRONMENT'] not in envfilter if request.method == 'POST': requestdata = request.get_json() search = requestdata[('term')] app.logger.debug(search) envfilter = requestdata['ENVIRONMENT'] if 'ENVIRONMENT' in requestdata else [] else: