prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Code listing for app.py in "look” Tutorial has a bug
  In the [Serving images](https://falcon.readthedocs.io/en/stable/user/tutorial.html#serving-images) section, the code listing for `app.py` tries to import the `images` module as `import images`. I believe this should be `from look import images` or depending on one's preferences `import look.images` and refactor references to `images` as `look.images`. I prefer the former:
  
  ```python
  import os
  
  import falcon
  
  from look import images
  
  
  def create_app(image_store):
      api = falcon.API()
      api.add_route('/images', images.Collection(image_store))
      api.add_route('/images/{name}', images.Item(image_store))
      return api
  
  
  def get_app():
      storage_path = os.environ.get('LOOK_STORAGE_PATH', '.')
      image_store = images.ImageStore(storage_path)
      return create_app(image_store)
  ```
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `falcon/media/validators/jsonschema.py`
  Content:
  ```
  1 from functools import wraps
  2 from inspect import iscoroutinefunction
  3 
  4 import falcon
  5 
  6 try:
  7     import jsonschema
  8 except ImportError:  # pragma: nocover
  9     pass
  10 
  11 
  12 def validate(req_schema=None, resp_schema=None, is_async=False):
  13     """Validate ``req.media`` using JSON Schema.
  14 
  15     This decorator provides standard JSON Schema validation via the
  16     ``jsonschema`` package available from PyPI. Semantic validation via
  17     the *format* keyword is enabled for the default checkers implemented
  18     by ``jsonschema.FormatChecker``.
  19 
  20     Note:
  21         The `jsonschema`` package must be installed separately in order to use
  22         this decorator, as Falcon does not install it by default.
  23 
  24         See `json-schema.org <http://json-schema.org/>`_ for more
  25         information on defining a compatible dictionary.
  26 
  27     Keyword Args:
  28         req_schema (dict): A dictionary that follows the JSON
  29             Schema specification. The request will be validated against this
  30             schema.
  31         resp_schema (dict): A dictionary that follows the JSON
  32             Schema specification. The response will be validated against this
  33             schema.
  34         is_async (bool): Set to ``True`` for ASGI apps to provide a hint that
  35             the decorated responder is a coroutine function (i.e., that it
  36             is defined with ``async def``) or that it returns an awaitable
  37             coroutine object.
  38 
  39             Normally, when the function source is declared using ``async def``,
  40             the resulting function object is flagged to indicate it returns a
  41             coroutine when invoked, and this can be automatically detected.
  42             However, it is possible to use a regular function to return an
  43             awaitable coroutine object, in which case a hint is required to let
  44             the framework know what to expect. Also, a hint is always required
  45             when using a cythonized coroutine function, since Cython does not
  46             flag them in a way that can be detected in advance, even when the
  47             function is declared using ``async def``.
  48 
  49     Example:
  50 
  51         .. tabs::
  52 
  53             .. tab:: WSGI
  54 
  55                 .. code:: python
  56 
  57                     from falcon.media.validators import jsonschema
  58 
  59                     # -- snip --
  60 
  61                     @jsonschema.validate(my_post_schema)
  62                     def on_post(self, req, resp):
  63 
  64                     # -- snip --
  65 
  66             .. tab:: ASGI
  67 
  68                 .. code:: python
  69 
  70                     from falcon.media.validators import jsonschema
  71 
  72                     # -- snip --
  73 
  74                     @jsonschema.validate(my_post_schema)
  75                     async def on_post(self, req, resp):
  76 
  77                     # -- snip --
  78 
  79             .. tab:: ASGI (Cythonized App)
  80 
  81                 .. code:: python
  82 
  83                     from falcon.media.validators import jsonschema
  84 
  85                     # -- snip --
  86 
  87                     @jsonschema.validate(my_post_schema, is_async=True)
  88                     async def on_post(self, req, resp):
  89 
  90                     # -- snip --
  91 
  92     """
  93 
  94     def decorator(func):
  95         if iscoroutinefunction(func) or is_async:
  96             return _validate_async(func, req_schema, resp_schema)
  97 
  98         return _validate(func, req_schema, resp_schema)
  99 
  100     return decorator
  101 
  102 
  103 def _validate(func, req_schema=None, resp_schema=None):
  104     @wraps(func)
  105     def wrapper(self, req, resp, *args, **kwargs):
  106         if req_schema is not None:
  107             try:
  108                 jsonschema.validate(
  109                     req.media, req_schema, format_checker=jsonschema.FormatChecker()
  110                 )
  111             except jsonschema.ValidationError as e:
  112                 raise falcon.HTTPBadRequest(
  113                     title='Request data failed validation', description=e.message
  114                 )
  115 
  116         result = func(self, req, resp, *args, **kwargs)
  117 
  118         if resp_schema is not None:
  119             try:
  120                 jsonschema.validate(
  121                     resp.media, resp_schema, format_checker=jsonschema.FormatChecker()
  122                 )
  123             except jsonschema.ValidationError:
  124                 raise falcon.HTTPInternalServerError(
  125                     title='Response data failed validation'
  126                     # Do not return 'e.message' in the response to
  127                     # prevent info about possible internal response
  128                     # formatting bugs from leaking out to users.
  129                 )
  130 
  131         return result
  132 
  133     return wrapper
  134 
  135 
  136 def _validate_async(func, req_schema=None, resp_schema=None):
  137     @wraps(func)
  138     async def wrapper(self, req, resp, *args, **kwargs):
  139         if req_schema is not None:
  140             m = await req.get_media()
  141 
  142             try:
  143                 jsonschema.validate(
  144                     m, req_schema, format_checker=jsonschema.FormatChecker()
  145                 )
  146             except jsonschema.ValidationError as e:
  147                 raise falcon.HTTPBadRequest(
  148                     title='Request data failed validation', description=e.message
  149                 )
  150 
  151         result = await func(self, req, resp, *args, **kwargs)
  152 
  153         if resp_schema is not None:
  154             try:
  155                 jsonschema.validate(
  156                     resp.media, resp_schema, format_checker=jsonschema.FormatChecker()
  157                 )
  158             except jsonschema.ValidationError:
  159                 raise falcon.HTTPInternalServerError(
  160                     title='Response data failed validation'
  161                     # Do not return 'e.message' in the response to
  162                     # prevent info about possible internal response
  163                     # formatting bugs from leaking out to users.
  164                 )
  165 
  166         return result
  167 
  168     return wrapper
  169
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/falcon/media/validators/jsonschema.py b/falcon/media/validators/jsonschema.py
  --- a/falcon/media/validators/jsonschema.py
  +++ b/falcon/media/validators/jsonschema.py
  @@ -18,7 +18,7 @@
       by ``jsonschema.FormatChecker``.
   
       Note:
  -        The `jsonschema`` package must be installed separately in order to use
  +        The ``jsonschema`` package must be installed separately in order to use
           this decorator, as Falcon does not install it by default.
   
           See `json-schema.org <http://json-schema.org/>`_ for more
  
verification_info: {"golden_diff": "diff --git a/falcon/media/validators/jsonschema.py b/falcon/media/validators/jsonschema.py\n--- a/falcon/media/validators/jsonschema.py\n+++ b/falcon/media/validators/jsonschema.py\n@@ -18,7 +18,7 @@\n     by ``jsonschema.FormatChecker``.\n \n     Note:\n-        The `jsonschema`` package must be installed separately in order to use\n+        The ``jsonschema`` package must be installed separately in order to use\n         this decorator, as Falcon does not install it by default.\n \n         See `json-schema.org <http://json-schema.org/>`_ for more\n", "issue": "Code listing for app.py in \"look\u201d Tutorial has a bug\nIn the [Serving images](https://falcon.readthedocs.io/en/stable/user/tutorial.html#serving-images) section, the code listing for `app.py` tries to import the `images` module as `import images`. I believe this should be `from look import images` or depending on one's preferences `import look.images` and refactor references to `images` as `look.images`. I prefer the former:\r\n\r\n```python\r\nimport os\r\n\r\nimport falcon\r\n\r\nfrom look import images\r\n\r\n\r\ndef create_app(image_store):\r\n    api = falcon.API()\r\n    api.add_route('/images', images.Collection(image_store))\r\n    api.add_route('/images/{name}', images.Item(image_store))\r\n    return api\r\n\r\n\r\ndef get_app():\r\n    storage_path = os.environ.get('LOOK_STORAGE_PATH', '.')\r\n    image_store = images.ImageStore(storage_path)\r\n    return create_app(image_store)\r\n```\r\n\n", "before_files": [{"content": "from functools import wraps\nfrom inspect import iscoroutinefunction\n\nimport falcon\n\ntry:\n    import jsonschema\nexcept ImportError:  # pragma: nocover\n    pass\n\n\ndef validate(req_schema=None, resp_schema=None, is_async=False):\n    \"\"\"Validate ``req.media`` using JSON Schema.\n\n    This decorator provides standard JSON Schema validation via the\n    ``jsonschema`` package available from PyPI. Semantic validation via\n    the *format* keyword is enabled for the default checkers implemented\n    by ``jsonschema.FormatChecker``.\n\n    Note:\n        The `jsonschema`` package must be installed separately in order to use\n        this decorator, as Falcon does not install it by default.\n\n        See `json-schema.org <http://json-schema.org/>`_ for more\n        information on defining a compatible dictionary.\n\n    Keyword Args:\n        req_schema (dict): A dictionary that follows the JSON\n            Schema specification. The request will be validated against this\n            schema.\n        resp_schema (dict): A dictionary that follows the JSON\n            Schema specification. The response will be validated against this\n            schema.\n        is_async (bool): Set to ``True`` for ASGI apps to provide a hint that\n            the decorated responder is a coroutine function (i.e., that it\n            is defined with ``async def``) or that it returns an awaitable\n            coroutine object.\n\n            Normally, when the function source is declared using ``async def``,\n            the resulting function object is flagged to indicate it returns a\n            coroutine when invoked, and this can be automatically detected.\n            However, it is possible to use a regular function to return an\n            awaitable coroutine object, in which case a hint is required to let\n            the framework know what to expect. Also, a hint is always required\n            when using a cythonized coroutine function, since Cython does not\n            flag them in a way that can be detected in advance, even when the\n            function is declared using ``async def``.\n\n    Example:\n\n        .. tabs::\n\n            .. tab:: WSGI\n\n                .. code:: python\n\n                    from falcon.media.validators import jsonschema\n\n                    # -- snip --\n\n                    @jsonschema.validate(my_post_schema)\n                    def on_post(self, req, resp):\n\n                    # -- snip --\n\n            .. tab:: ASGI\n\n                .. code:: python\n\n                    from falcon.media.validators import jsonschema\n\n                    # -- snip --\n\n                    @jsonschema.validate(my_post_schema)\n                    async def on_post(self, req, resp):\n\n                    # -- snip --\n\n            .. tab:: ASGI (Cythonized App)\n\n                .. code:: python\n\n                    from falcon.media.validators import jsonschema\n\n                    # -- snip --\n\n                    @jsonschema.validate(my_post_schema, is_async=True)\n                    async def on_post(self, req, resp):\n\n                    # -- snip --\n\n    \"\"\"\n\n    def decorator(func):\n        if iscoroutinefunction(func) or is_async:\n            return _validate_async(func, req_schema, resp_schema)\n\n        return _validate(func, req_schema, resp_schema)\n\n    return decorator\n\n\ndef _validate(func, req_schema=None, resp_schema=None):\n    @wraps(func)\n    def wrapper(self, req, resp, *args, **kwargs):\n        if req_schema is not None:\n            try:\n                jsonschema.validate(\n                    req.media, req_schema, format_checker=jsonschema.FormatChecker()\n                )\n            except jsonschema.ValidationError as e:\n                raise falcon.HTTPBadRequest(\n                    title='Request data failed validation', description=e.message\n                )\n\n        result = func(self, req, resp, *args, **kwargs)\n\n        if resp_schema is not None:\n            try:\n                jsonschema.validate(\n                    resp.media, resp_schema, format_checker=jsonschema.FormatChecker()\n                )\n            except jsonschema.ValidationError:\n                raise falcon.HTTPInternalServerError(\n                    title='Response data failed validation'\n                    # Do not return 'e.message' in the response to\n                    # prevent info about possible internal response\n                    # formatting bugs from leaking out to users.\n                )\n\n        return result\n\n    return wrapper\n\n\ndef _validate_async(func, req_schema=None, resp_schema=None):\n    @wraps(func)\n    async def wrapper(self, req, resp, *args, **kwargs):\n        if req_schema is not None:\n            m = await req.get_media()\n\n            try:\n                jsonschema.validate(\n                    m, req_schema, format_checker=jsonschema.FormatChecker()\n                )\n            except jsonschema.ValidationError as e:\n                raise falcon.HTTPBadRequest(\n                    title='Request data failed validation', description=e.message\n                )\n\n        result = await func(self, req, resp, *args, **kwargs)\n\n        if resp_schema is not None:\n            try:\n                jsonschema.validate(\n                    resp.media, resp_schema, format_checker=jsonschema.FormatChecker()\n                )\n            except jsonschema.ValidationError:\n                raise falcon.HTTPInternalServerError(\n                    title='Response data failed validation'\n                    # Do not return 'e.message' in the response to\n                    # prevent info about possible internal response\n                    # formatting bugs from leaking out to users.\n                )\n\n        return result\n\n    return wrapper\n", "path": "falcon/media/validators/jsonschema.py"}], "after_files": [{"content": "from functools import wraps\nfrom inspect import iscoroutinefunction\n\nimport falcon\n\ntry:\n    import jsonschema\nexcept ImportError:  # pragma: nocover\n    pass\n\n\ndef validate(req_schema=None, resp_schema=None, is_async=False):\n    \"\"\"Validate ``req.media`` using JSON Schema.\n\n    This decorator provides standard JSON Schema validation via the\n    ``jsonschema`` package available from PyPI. Semantic validation via\n    the *format* keyword is enabled for the default checkers implemented\n    by ``jsonschema.FormatChecker``.\n\n    Note:\n        The ``jsonschema`` package must be installed separately in order to use\n        this decorator, as Falcon does not install it by default.\n\n        See `json-schema.org <http://json-schema.org/>`_ for more\n        information on defining a compatible dictionary.\n\n    Keyword Args:\n        req_schema (dict): A dictionary that follows the JSON\n            Schema specification. The request will be validated against this\n            schema.\n        resp_schema (dict): A dictionary that follows the JSON\n            Schema specification. The response will be validated against this\n            schema.\n        is_async (bool): Set to ``True`` for ASGI apps to provide a hint that\n            the decorated responder is a coroutine function (i.e., that it\n            is defined with ``async def``) or that it returns an awaitable\n            coroutine object.\n\n            Normally, when the function source is declared using ``async def``,\n            the resulting function object is flagged to indicate it returns a\n            coroutine when invoked, and this can be automatically detected.\n            However, it is possible to use a regular function to return an\n            awaitable coroutine object, in which case a hint is required to let\n            the framework know what to expect. Also, a hint is always required\n            when using a cythonized coroutine function, since Cython does not\n            flag them in a way that can be detected in advance, even when the\n            function is declared using ``async def``.\n\n    Example:\n\n        .. tabs::\n\n            .. tab:: WSGI\n\n                .. code:: python\n\n                    from falcon.media.validators import jsonschema\n\n                    # -- snip --\n\n                    @jsonschema.validate(my_post_schema)\n                    def on_post(self, req, resp):\n\n                    # -- snip --\n\n            .. tab:: ASGI\n\n                .. code:: python\n\n                    from falcon.media.validators import jsonschema\n\n                    # -- snip --\n\n                    @jsonschema.validate(my_post_schema)\n                    async def on_post(self, req, resp):\n\n                    # -- snip --\n\n            .. tab:: ASGI (Cythonized App)\n\n                .. code:: python\n\n                    from falcon.media.validators import jsonschema\n\n                    # -- snip --\n\n                    @jsonschema.validate(my_post_schema, is_async=True)\n                    async def on_post(self, req, resp):\n\n                    # -- snip --\n\n    \"\"\"\n\n    def decorator(func):\n        if iscoroutinefunction(func) or is_async:\n            return _validate_async(func, req_schema, resp_schema)\n\n        return _validate(func, req_schema, resp_schema)\n\n    return decorator\n\n\ndef _validate(func, req_schema=None, resp_schema=None):\n    @wraps(func)\n    def wrapper(self, req, resp, *args, **kwargs):\n        if req_schema is not None:\n            try:\n                jsonschema.validate(\n                    req.media, req_schema, format_checker=jsonschema.FormatChecker()\n                )\n            except jsonschema.ValidationError as e:\n                raise falcon.HTTPBadRequest(\n                    title='Request data failed validation', description=e.message\n                )\n\n        result = func(self, req, resp, *args, **kwargs)\n\n        if resp_schema is not None:\n            try:\n                jsonschema.validate(\n                    resp.media, resp_schema, format_checker=jsonschema.FormatChecker()\n                )\n            except jsonschema.ValidationError:\n                raise falcon.HTTPInternalServerError(\n                    title='Response data failed validation'\n                    # Do not return 'e.message' in the response to\n                    # prevent info about possible internal response\n                    # formatting bugs from leaking out to users.\n                )\n\n        return result\n\n    return wrapper\n\n\ndef _validate_async(func, req_schema=None, resp_schema=None):\n    @wraps(func)\n    async def wrapper(self, req, resp, *args, **kwargs):\n        if req_schema is not None:\n            m = await req.get_media()\n\n            try:\n                jsonschema.validate(\n                    m, req_schema, format_checker=jsonschema.FormatChecker()\n                )\n            except jsonschema.ValidationError as e:\n                raise falcon.HTTPBadRequest(\n                    title='Request data failed validation', description=e.message\n                )\n\n        result = await func(self, req, resp, *args, **kwargs)\n\n        if resp_schema is not None:\n            try:\n                jsonschema.validate(\n                    resp.media, resp_schema, format_checker=jsonschema.FormatChecker()\n                )\n            except jsonschema.ValidationError:\n                raise falcon.HTTPInternalServerError(\n                    title='Response data failed validation'\n                    # Do not return 'e.message' in the response to\n                    # prevent info about possible internal response\n                    # formatting bugs from leaking out to users.\n                )\n\n        return result\n\n    return wrapper\n", "path": "falcon/media/validators/jsonschema.py"}]}