Question 20
Consider the following flask application running on the base URL and is accessed through a browser. Select the correct option(s).
app = Flask(__name__)
users = { 1 : {"Name": "Mukesh", "role": "Admin", "access": True}, 2 : {"Name": "Gautam", "role": "User", "access": True}, 3 : {"Name": "Narendra", "role": "Admin", "access": True}, 4 : {"Name": "Amit", "role": "User", "access": False} }
@app.route('/login')def auth(): cred = request.args if users[int(cred["id"])].get("access"): id = int(cred["id"]) user = users[id] return "Welcome, "+ user.get("Name")+", you have "+user.get("role")+ " access" else: abort(403)
@app.errorhandler(403)def no_access(error): return "You are an unauthorized user!"
app.run(debug = True)