Our Flask integration lets you instrument individual HTTP requests by adding a dedicated WSGI middleware to your application.
Wrap your application with
FlaskMiddleware (the code is part of the
blackfire package when you install Blackfire for Python):
1 2 3 4 5 6 7 8
from flask import Flask app = Flask(__name__) from blackfire.middleware import FlaskMiddleware app.wsgi_app = FlaskMiddleware(app) # You can now define your routes and controllers
When chaining WSGI middleware, the order is important. You should include Blackfire as early as possible in the list. However, it must come after any response content encoders (such as gzip for example).