Question 18
A flask application shown below is running locally on http://127.0.0.1:5000.
from flask import Flask, request, session, abort
app = Flask(__name__)app.config['SECRET_KEY'] = "yekterces"
@app.route('/login')def log_in(): user = request.args['user'] role = request.args['role'] if 'role' in request.args else'general' session['user'], session['role'] = user, role return "Logged in successfully!"
@app.route('/home')def land(): if 'user' in session: if session['role'] == 'admin': return f"Welcome {session['user']}" return abort(401) return abort(404)
@app.route('/logout')def log_out(): session.pop('user', None) session.pop('role', None) return "Logged out sucessfully!"
app.run(debug=True)If the application is running locally on http://127.0.0.1:5000, What will be the correct sequence of response status codes if the client visits the URLs one by one in the sequence given below?
http://127.0.0.1:5000/homehttp://127.0.0.1:5000/login/adminhttp://127.0.0.1:5000/login?user=adminhttp://127.0.0.1:5000/homehttp://127.0.0.1:5000/logout