Using ProfileMiddleware with sort columns

Report a typo

In this problem, create a Flask app and see how to configure the ProfileMiddleware to add columns to sort. For this example, we will sort by two columns tottime and cumtime, which are output in profiling logs. Complete the below code

  • Add the necessary ProfileMiddleware code to enable profiling;
  • Make sure you use sort_by_columns to pass the variables to sort by;
  • Follow the middleware initialization practices of Flask of using app.wsgi_app.
Write a program in Python 3
from flask import Flask
from werkzeug.middleware.profiler import ProfilerMiddleware
sort_by_columns = ('tottime', 'cumtime')
app = Flask(__name__)
# Enter your code here

Create a free account to access the full topic