July 2019
Beginner to intermediate
302 pages
9h 38m
English
Create a new file, generate_profile.py, alongside run.py, which works like run.py itself, but with ProfilerMiddleware:
from werkzeug.middleware.profiler import ProfilerMiddleware from my_app import app app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions = [10]) app.run(debug=True)
Here, we imported ProfilerMiddleware from werkzeug and then modified wsgi_app on our Flask app to use it, with a restriction of the top 10 calls to be printed in the output.