Answered step by step
Verified Expert Solution
Question
1 Approved Answer
of the function is missing. return jsonify(results) @app.route(/api/v1.o/passengers) def passengers(): Return a list of passenger data including the name, age, and sex of each passenger
of the function is missing. return jsonify(results) @app.route("/api/v1.o/passengers") def passengers(): ""Return a list of passenger data including the name, age, and sex of each passenger" " \# Query all passengers session = Session(engine) results = session.query(Passenger.name, Passenger.age, Passenger.sex).all() \# Create a dictionary from the row data and append to a list of all_passengers all_passengers = [] for name, age, sex in results: passenger_dict = \{\} passenger_dict["name"] = name passenger_dict["age"] = age passenger_dict["sex"] = sex all_passengers.append(passenger_dict) \#\#\# Return list of all passenger data in Json format \#\#\# if name == '_main_: app.run(debug=True) On line 52, what line of code needs to be inserted so that the list of all passenger data will be sent to the end-point in JSON format? return all_passengers.json() return json(all_passengers) return jsonify(all_passengers) return all_passengers
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started