def similar(self, artist, callback=None, _=''): cherrypy.response.headers["Access-Control-Allow-Origin"] = "*" if callback: cherrypy.response.headers['Content-Type']= 'text/javascript' else: cherrypy.response.headers['Content-Type']= 'application/json' start_time = time.time() results = {} seed, sims = graph.sim_artist(artist) if sims: results['status'] = 'ok' results['seed'] = graph.get_artist(seed) results['sims'] = [graph.get_artist(id) for id in sims] else: results['status'] = 'error' results['time'] = time.time() - start_time return to_json(results, callback)
def find_path(self, start, end, skips=None, callback=None, _=''): cherrypy.response.headers["Access-Control-Allow-Origin"] = "*" if callback: cherrypy.response.headers['Content-Type']= 'text/javascript' else: cherrypy.response.headers['Content-Type']= 'application/json' start_time = time.time() skips = make_list(skips) status, path = graph.find_path(start, end, skips) results = {} results['status'] = status if path: results['path'] = [graph.get_artist(id) for id in path] results['time'] = time.time() - start_time return to_json(results, callback)