Question 8
Consider the following flask resource created using flask_restful.
from flask import Flask, requestfrom flask_restful import Api, Resource, reqparse
app = Flask(__name__)api = Api(app)
parser = reqparse.RequestParser()parser.add_argument("val")
class RestApi(Resource): def post(self, val): arg1 = parser.parse_args() arg2 = request.args return { "Course_1": arg1["val"], "Course_2": arg2["val"], "Course_3": val }
api.add_resource(RestApi, "/api/courses/<val>")app.run(debug = True)If the application is running locally on http://127.0.0.1:5000, What will be the output on the terminal for the command:
curl http://127.0.0.1:5000/api/courses/DBMS?val=JAVA -d"{\"val\":\"PDSA\"}" -X POST -H "Content-Type: application/json"