Quiz Space

Modern Application Development I · Quiz 1 · 27 Oct 2024 · September 2024 term

Question 10: Consider the following Python code snippet. Filename: ap…

Question 10

+4.5 marksOne correct option

Consider the following Python code snippet.

Filename: app.py

python
from flask import Flask, request
import sys
app = Flask(__name__)
@app.route('/home', methods = sys.argv)
def my_func():
if request.method == 'GET':
return "<h1>Hello from POST</h1>"
elif request.method == 'POST':
return "<h1>Hello from GET</h1>"
else:
return "<h1>Please enter a valid HTTP method<h1>"
app.run(debug = True)

If the above flask app is run using the command python app.py GET POST in one terminal, what will be the output on another terminal for command; curl http://127.0.0.1:5000/home ?

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

Correct answer

  • B

Question 10 of 16 in the IIT Madras BS Modern Application Development I (MAD 1) Quiz 1 paper sat on 27 Oct 2024, in the September 2024 term (IIT M DIPLOMA AN EXAM QDD2 27 Oct 2024). It carries 4.5 marks.

More questions from this paper

  1. Q1Suppose a Gamer wants to buy a Bluetooth earphone which can give him a good gaming experience, for that the delay betwe…
  2. Q2Figure question
  3. Q3Consider the following HTML code and select the correct rendered output from the following.
  4. Q4Consider the following code block and select the correct option regarding the output when we run the python file app.py…
  5. Q5The following Python code snippet generates the output on the terminal. Which of the following is the correct output?
  6. Q6The directory listing of a folder and the content of each of its files are given below. Directory Listing: Filename: ba…
  7. Q7Consider the following Python code and select correct output.
  8. Q8Figure question
  9. Q9A certain network connection with a bandwidth of 10 Mbps allows making 1000 requests to a server per second. If each re…
  10. Q11Figure question
  11. Q12Figure question
  12. Q13Consider the flask code below. Assume that the above flask application is running on http://127.0.0.1:5000 . Which of t…
  13. Q14Consider the following code snippet. Assume the database has a "product" table represented by class "Product" which has…
  14. Q15Consider the following code and answer the given subquestions. form.html app.py
  15. Q16Consider the following code and answer the given subquestions. form.html app.py