app.py
def stations():
    """Return JSON API for all stations in dataset."""

    print("Stations API request received.")

    # Create our session (link) from Python to the DB
    session = Session(engine)
    # Query all stations in the dataset.
    stations = session.query(Station.id, Station.station, Station.name, Station.latitude, Station.longitude, Station.elevation).all()

    # Iterate through stations to append all key/values to station dictionary.
    # Append station dictionary to list, then return jsonify. 
    all_stations = []
    for id, station, name, latitude, longitude, elevation in stations:
        station_dict = {}
        station_dict["id"] = id
        station_dict["station"] = station
        station_dict["name"] = name
        station_dict["latitude"] = latitude
        station_dict["longitude"] = longitude
        station_dict["elevation"] = elevation
        all_stations.append(station_dict)

    return jsonify(all_stations)
Return JSON API for all stations in dataset.
Return JSON API for all stations in dataset.
Return JSON API for all stations in dataset .
def stations():
    print("Stations API request received.")
    session = Session(engine)
    stations = session.query(Station.id, Station.station, Station.name, Station.latitude, Station.longitude, Station.elevation).all()
    all_stations = []
    for id, station, name, latitude, longitude, elevation in stations:
        station_dict = {}
        station_dict["id"] = id
        station_dict["station"] = station
        station_dict["name"] = name
        station_dict["latitude"] = latitude
        station_dict["longitude"] = longitude
        station_dict["elevation"] = elevation
        all_stations.append(station_dict)
    return jsonify(all_stations)
def stations ( ) : print ( "Stations API request received." ) session = Session ( engine ) stations = session . query ( Station . id , Station . station , Station . name , Station . latitude , Station . longitude , Station . elevation ) . all ( ) all_stations = [ ] for id , station , name , latitude , longitude , elevation in stations : station_dict = { } station_dict [ "id" ] = id station_dict [ "station" ] = station station_dict [ "name" ] = name station_dict [ "latitude" ] = latitude station_dict [ "longitude" ] = longitude station_dict [ "elevation" ] = elevation all_stations . append ( station_dict ) return jsonify ( all_stations )
Return JSON API for all stations in dataset.
Return JSON API for all stations in dataset .
"""Return JSON API for all stations in dataset.""" # Create our session (link) from Python to the DB # Query all stations in the dataset. # Iterate through stations to append all key/values to station dictionary. # Append station dictionary to list, then return jsonify. 