Using ProfileMiddleware with restrictions

Report a typo

In this problem, create a Flask app and see how to configure the ProfileMiddleware to add restrictions for output logs. We will filter the profile logs with the current file name for this example. Complete the below code

  • Add the necessary ProfileMiddleware code to enable profiling;
  • Make sure you use current_file_name to pass the variables to restrict 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
import os

current_file_name = os.path.basename(__file__)
app = Flask(__name__)
# Enter your code here

Create a free account to access the full topic