Question 15
Consider the following Flask-RESTful API implementation:
from flask import Flask, requestfrom flask_restful import Resource, Api
app = Flask(__name__)api = Api(app)
students = { 1: {"name": "Arjun", "grade": "A"}, 2: {"name": "Kiran", "grade": "B+"}, 3: {"name": "Meera", "grade": "A"},}
class Student(Resource): def get(self, student_id): if student_id in students: return students[student_id], 200 return {"message": "Student not found"}, 404
def put(self, student_id): data = request.json if student_id in students: students[student_id]["grade"] = data.get("grade",students[student_id]["grade"]) return {"message": "Student record updated", "student":students[student_id]}, 200 return {"message": "Student not found"}, 404
api.add_resource(Student, "/student/<int:student_id>")
if __name__ == "__main__": app.run(debug=True)The API is running on http://127.0.0.1:5000/. Which of the following statements about this API's behavior is correct?