Using a filter will allow for a URL variable to be used as a query filter. The string variable will be checked against the state name field in the database table, and uses a like operator to do a fuzzy comparison (that is, it will get all states that start with 'M' if the state_name variable is 'M':
@app.route('/nba/api/v0.1/state/<state_name>', methods=['GET'])def get_state_name(state_name): states = session.query(State).filter(State.name.like(state_name+"%")).all() geoms = {state.id:smapping(to_shape(state.geom)) for state in states} data = [{"type": "Feature", "properties":{"state":state.name}, "geometry":{"type":"MultiPolygon", "coordinates":[shapely.geometry.geo.mapping(to_shape(state.geom)["coordinates"]]}, ...