Using ProfileMiddleware with profile directory

Report a typo

In this problem, create a Flask app and see how to configure the ProfileMiddleware to add profile_dir for saving output logs. For this example, we will save the profile logs to the profile_dir variable. Complete the below code

  • Add the necessary ProfileMiddleware code to enable profiling;
  • Make sure you save the profile log using the save_to variable;
  • 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

save_to = "./profile_dir"
app = Flask(__name__)
# Enter your code here
___

Create a free account to access the full topic