Question 31
Consider the below program, and answer the given subquestions, if the application is running locally on URL: http://127.0.0.1:5000.
Consider the following resource created with help of flask-restful.
parser = reqparse.RequestParser()parser.add_argument('employee_id')parser.add_argument('employee_name')
r_fields = {"Name":fields.String(attribute = 'employee_name')}
class TestAPI(Resource):
# ===============================================# GET-FUNCTION# ===============================================# ===============================================# POST-FUNCTION# =============================================== @marshal_with(r_fields) def put(self): this_emp = parser.parse_args() return this_emp
api.add_resource(TestAPI, "/api/v1", "/api/v1/<employee_id>")If the curl request shown below.
curl http://127.0.0.1:5000/api/v1 -X POST -d "{\"employee_id\" : \"2003\",\"employee_name\": \"Suresh\"}" -H "Content-Type: application/json"retrieves the employee_id only with status 200 OK, what will come in place of POST-FUNCTION in the code?