Getting all districts

This endpoint, ('/district'), will query against the District model using session.query(District).all():

@app.route('/nba/api/v0.1/district', methods=['GET'])def get_districts():  districts = session.query(District).all()  if 'geometry' in request.args.keys() and request.args['geometry'] in ('1','True'):    data = [{"type": "Feature",     "properties":{"representative":district.name, "district":district.district, "state": district.state_ref.name, "id":district.id},     "geometry":{"type":"MultiPolygon",     "coordinates":shapely.geometry.geo.mapping(to_shape(district.geom))["coordinates"]},    } for district in districts]  else:    data = [{"type": "Feature",     "properties":{"representative":district.name, "district":district.district, "state": ...

Get Mastering Geospatial Analysis with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.