def search(request, input): results = {} results['routes'] = [ formats.route_to_dict(route) for route in queries.search_routes(input) ] if len(input) > 3: results['stops'] = [ formats.stop_to_dict(stop) for stop in queries.search_stops(input) ] return HttpResponse(formats.dict_to_json(results), mimetype='application/json')
def get_trip_from_id(request, trip_id): trip = formats.trip_to_dict(queries.get_trip_from_id(trip_id)) return HttpResponse(formats.dict_to_json(trip), mimetype='application/json')
def get_num_stops_within_bounds(request, n, s, e, w): num_stops = queries.get_num_stops_within_bounds(n, s, e, w) return HttpResponse(formats.dict_to_json({'num_stops': num_stops}), mimetype='application/json')