Question 1
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?