code: def test_async_before_after_request():
      app_before_called = False
      app_after_called = False
      bp_before_called = False
      bp_after_called = False
  
      app = Flask(__name__)
  
      @app.route("/")
      def index():
          return ""
  
      @app.before_request
      async def before():
          nonlocal app_before_called
          app_before_called = True
  
      @app.after_request
      async def after(response):
          nonlocal app_after_called
          app_after_called = True
          return response
  
      blueprint = Blueprint("bp", __name__)
  
      @blueprint.route("/")
      def bp_index():
          return ""
  
      @blueprint.before_request
      async def bp_before():
          nonlocal bp_before_called
          bp_before_called = True
  
      @blueprint.after_request
      async def bp_after(response):
          nonlocal bp_after_called
          bp_after_called = True
          return response
  
      app.register_blueprint(blueprint, url_prefix="/bp")
  
      test_client = app.test_client()
      test_client.get("/")
      assert app_before_called
      assert app_after_called
      test_client.get("/bp/")
      assert bp_before_called
      assert bp_after_called
  
file_path: flask/tests/test_async.py
imports: import asyncio
  import pytest
  from flask import Blueprint
  from flask import Flask
  from flask import request
  from flask.views import MethodView
  from flask.views import View
label_desc: Use image node_id 4 for calling a global function with example usage: test_async_before_after_request() and returns: str, response, str, response