def METHOD_NAME(app: Flask) -> None:
    try:
        from pyinstrument import Profiler
    except ImportError:
        app.logger.info("in debug mode, but pyinstrument not installed.")
        return
    @app.before_request
    def before_request() -> None:
        if "profile" in request.args:
            g.profiler = Profiler()
            g.profiler.start()
    @app.after_request
    def after_request(response: Response) -> Response:
        if not hasattr(g, "profiler"):
            return response
        g.profiler.stop()
        output_html = g.profiler.output_html()
        return make_response(output_html)