def view_3d_offline(): pt_vars = {}; pt_vars['offline_mode'] = True pt_vars['score_rankings'] = json.dumps(api.rankings('score', 4000, True), allow_nan=False) pt_vars['value_rankings'] = json.dumps(api.rankings('value', 4000, True), allow_nan=False) pt_vars['accessibility_rankings'] = json.dumps(api.rankings('accessibility', 4000, True), allow_nan=False) pt_vars['smallest_rankings'] = json.dumps(api.rankings('smallest', 4000, True), allow_nan=False) return render_template('full3d.html', noop=noop_filter, passthrough_vars=pt_vars, \ offline_mode=True)
def track_ws(ws): results = api.rankings("closeness", 4000) sim_running = False while True: message = ws.receive() print message if message != "" and sim_running == False: rocket = getRocketParticle(obj=json.loads(message)) sim.simulate(rocket, results) ws.send(message)
def rankings(): try: limit = int(request.args.get('limit')) or 10 results = api.rankings(request.args.get('sort_by'), limit) json_resp = json.dumps(results) return Response(json_resp, mimetype='application/json', headers={ \ 'Cache-Control': 'max-age=432000', # 5 days }) except: resp = jsonify({'error': 'bad request'}) resp.status_code = 500 return resp
def rankings(): try: limit = int(request.args.get('limit')) or 10 orbital_info_only = request.args.get('orbits_only') results = api.rankings(request.args.get('sort_by'), limit, orbits_only=orbital_info_only) json_resp = json.dumps(results) return Response(json_resp, mimetype='application/json', headers={ \ 'Cache-Control': 'max-age=432000', # 5 days }) except Exception, e: resp = jsonify({'error': 'bad request', 'details': str(e)}) resp.status_code = 500 return resp
def rankings(): try: order_by = json.loads(request.args.get('sortBy')) limit = int(request.args.get('limit')) or 10 page = int(request.args.get('page')) or 1 search_criteria = json.loads(request.args.get('searchCriteria')) orbital_info_only = request.args.get('orbits_only') results = api.rankings(search_criteria, order_by, limit, page, orbital_info_only) json_resp = json.dumps(results, allow_nan=False) return Response(json_resp, mimetype='application/json', headers={ \ 'Cache-Control': 'max-age=432000', # 5 days }) except Exception,e: print str(e) resp = jsonify({'error': 'bad request'}) resp.status_code = 500 return resp