Modern Application Development I, Quiz 2
Consider the Python file and a template given below.
Python file: app.py
from flask import Flask, url_for, redirect, render_templateapp = 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
<!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?
Consider the Python file and a template given below.\ Python file: app.py 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 <!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? A flask application is given below. from flask import Flask, jsonify app = Flask(__name__) Gadgets = [ {"tech":"Smartwatch, Digital camera"}, {"mobile":"Headphones, Speakers"}, {"Laptop":"Keyboard, Mouse"} ] @app.route("/home", methods=["GET"]) def func1(): return jsonify({"The list of gadgets": Gadgets}) @app.route("//") def rest_lists(): return { "Restaurant 1" : "Hotel Alpine", "Restaurant 2" : "Maurya Vihar", "Restaurant 3" : "Royal Garden" } if __name__ == "__main__": app.run(debug=True) If the above flask application is running locally on the URL ‘http://127.0.0.1:5000’, which of the following statement is true about the above flask application? Consider the table “production” in SQLite database given below: Table of production data (Manufacturer, Product, Quantity, Cost) with an SQL GROUP BY query