Modern Application Development I, End Term
Which of the following correctly represents the components of the given URL?
Which of the following correctly represents the components of the given URL? Figure from the original question paper Consider the following flask app and an HTML file in templates folder: Python file: app.py from flask import Flask, render_template app = Flask(__name__) my_list = ['Web development','onlinedegree','cs2003', 'MAD-I','Data_science'] @app.route('/') def render(): return render_template('index.html', my_list = my_list) app.run(debug = True) Template file: <!DOCTYPE html> <head> <style> body{width: 200px; border: 2px solid black} #one{color:red;} #two{color:blue;} </style> </head> <body> {% for item in my_list %} {% set Length = item|length %} {% if Length%2 == 0 %} <h3 id = "one">{{ item }}</h3> {% else %} <h3 id = "two">{{ item }}</h3> {% endif %} {% endfor %} </body> If the above flask app is running locally on <u>http://127.0.0.1:5000/</u>, what will be rendered by the browser for the base URL? Consider the flask code given below. Python file: app.py from flask import Flask, jsonify, request app = Flask(__name__) my_shops= [ { 'name of the shop' : 'Grocery', 'items' : [ { 'item1' : 'Toothpaste', 'item2' : 'Snacks', 'item3' : 'Biscuits', 'item4' : 'Soaps' } ] } ] @app.route('/') def show_shop(): return jsonify({"shops" : my_shops}) #====================== CODE HERE #====================== if __name__ == '__main__': app.run() Which of the following code snippets must be added in the given space of above application, in order to create a new shop in ‘my\_shops’ list on the server side apart from the existing one?