Quiz Space

Modern Application Development I · Quiz 2 · 10 Jul 2022 · May 2022 term

Question 1: Consider the Python file and a template given below.\ Pyt…

Question 1

+3 marksOne or more correct options

Consider the Python file and a template given below.
Python file: app.py

python
from flask import Flask, url_for, redirect, render_template
app = Flask(__name__)
@app.route("/<name>/")
def index1(name):
return "Hi" + " " + name + "!" + " " + "This is your home page."
@app.route("/first_index/<string:name>")
def index2(name):
if name == "XYZ":
return redirect(url_for("index1", name = "XYZ"))
else:
return redirect( url_for("index3"))
@app.route("/second_index")
def index3():
return render_template("index.html")
if __name__ == "__main__":
app.run(debug=True)

Template file: index.html

html
<!DOCTYPE html>
<html lang="en">
<head>
<title>My Document</title>
</head>
<body>
<h2> You are on the incorrect page.</h2>
<a href="{{ url_for("index1", name="ABC") }}">Go back</a>
</body>
</html>

If the above flask application is running locally on the URL ‘http://127.0.0.1:5000’, which of the following statements is/are true about the above code snippet?

Select all that apply.

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

Correct answers

  • B
  • C

Question 1 of 16 in the IIT Madras BS Modern Application Development I (MAD 1) Quiz 2 paper sat on 10 Jul 2022, in the May 2022 term (IIT M DIPLOMA QUIZ2 EXAM QPE1 10 July 2022). It carries 3 marks.

More questions from this paper

  1. Q2A flask application is given below. If the above flask application is running locally on the URL ‘http://127.0.0.1:5000…
  2. Q3Consider the table “production” in SQLite database given below:
  3. Q4Consider the table “employee” given below. The model class “Employee” corresponds to table “employee” in the database.
  4. Q5Which of the following is the correct Python object representation of the given SQL query with declarative_base() class.
  5. Q6If the below flask application is running locally on the URL: ‘http://127.0.0.1:5000’, what will be rendered by the bro…
  6. Q7Consider the following table “table_A” in SQLite database.
  7. Q8Consider the following HTML file with embedded JavaScript.\ Filename: index.html How will the browser render the above …
  8. Q9Consider the statements given below.\ Statement 1: APIs usually contain SDKs, but SDKs do not contain APIs.\ Statement …
  9. Q10Consider a situation, where a developer wants to create his own customized application and wants to deploy it for the e…
  10. Q11Consider the following table ‘flowers’ in SQLite database.
  11. Q12Match the following based on the memory hierarchy of computer.
  12. Q13Consider the HTML document given below: Which of the following statements is true for the above HTML document when rend…
  13. Q14Consider the following PyHTML program. Identify the corresponding HTML file which will be generated on running the PyHT…
  14. Q15Figure question
  15. Q16Consider the following Python code snippet: If the application is running locally on the URL: “<u>http://127.0.0.1:5000…