Quiz Space

Modern Application Development I · Quiz 2 · 3 Aug 2025 · May 2025 term

Question 13: Consider the Flask Restful API code given below: File na…

Question 13

+4.5 marksOne or more correct options

Consider the Flask Restful API code given below:

File name: app.py

python
from flask import Flask, request
from 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

Select all that apply.

  1. A
  2. B
  3. C
  4. D
  5. E
Show answer

Correct answers

  • A
  • B
  • E

Question 13 of 16 in the IIT Madras BS Modern Application Development I (MAD 1) Quiz 2 paper sat on 3 Aug 2025, in the May 2025 term (IIT M DEGREE AN EXAM QDB2 03 Aug 2025). It carries 4.5 marks.

More questions from this paper

  1. Q1You manage a datacenter where each server has a 10 Gigabit per second network connection and the facility’s backbone li…
  2. Q2Which of the following statements BEST describes a key advantage of Jinja2 server-side rendering over JavaScript/JSON-b…
  3. Q3Figure question
  4. Q4What is the right syntax to use an external JavaScript file(.js) into the current html file?
  5. Q5Figure question
  6. Q6Consider the following Python code. File name: main.py What is the correct output of the given code?
  7. Q7Consider the following Python code snippet. Which of the following statements, when substituted in place of === OUTPUT …
  8. Q8Consider the following Flask app code. Assume the above flask app runs on “http://127.0.0.1:5000/” and is accessed thro…
  9. Q9Consider the following HTML code. Filename: main.html
  10. Q10Consider the following flask application. If the application is running locally on http://127.0.0.1:5000. What will be …
  11. Q11Which of the following statements is/are false about caching in REST APIs?
  12. Q12Which of the following is/are correct with respect to storing data in graphs?
  13. Q14Figure question
  14. Q15Consider the following sqlalchemy code and answer the given subquestions:
  15. Q16Consider the following sqlalchemy code and answer the given subquestions: