Question 13
Consider the Flask Restful API code given below:
File name: app.py
from flask import Flask, requestfrom flask_restful import Resource, Api
app = Flask(__name__)api = Api(app)
class APICalculator(Resource): def post(self): d = request.json a = int(d["val1"]) b = int(d["val2"]) oper = d["operator"] if oper == "+": return {"Sum=": (a + b)}, 200 elif oper == "-": return {"Difference=": (a - b)}, 200 elif oper == "*": return {"Product=": (a * b)}, 200 else: return {"Error": "Invalid option"}, 401
api.add_resource(APICalculator, "/")
app.run(debug=True)Assume that the Flask server is running on http://127.0.0.1:5000. Which of the following is the correct curl command(s) that will return calculated values?
Note: Assume data sent is valid for cmd, and powershell