prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Add front-end extension capability
  This is similar in concept to https://github.com/getredash/redash/pull/2354/files
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `redash/extensions.py`
  Content:
  ```
  1 from pkg_resources import iter_entry_points
  2 
  3 
  4 def init_extensions(app):
  5     """
  6     Load the Redash extensions for the given Redash Flask app.
  7     """
  8     if not hasattr(app, 'redash_extensions'):
  9         app.redash_extensions = {}
  10 
  11     for entry_point in iter_entry_points('redash.extensions'):
  12         app.logger.info('Loading Redash extension %s.', entry_point.name)
  13         extension = entry_point.load()
  14         app.redash_extensions[entry_point.name] = extension(app)
  15
  ```
  --- 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/redash/extensions.py b/redash/extensions.py
  --- a/redash/extensions.py
  +++ b/redash/extensions.py
  @@ -1,4 +1,5 @@
  -from pkg_resources import iter_entry_points
  +import os
  +from pkg_resources import iter_entry_points, resource_isdir, resource_listdir
   
   
   def init_extensions(app):
  @@ -10,5 +11,20 @@
   
       for entry_point in iter_entry_points('redash.extensions'):
           app.logger.info('Loading Redash extension %s.', entry_point.name)
  -        extension = entry_point.load()
  -        app.redash_extensions[entry_point.name] = extension(app)
  +        try:
  +            extension = entry_point.load()
  +            app.redash_extensions[entry_point.name] = {
  +                "entry_function": extension(app),
  +                "resources_list": []
  +            }
  +        except ImportError:
  +            app.logger.info('%s does not have a callable and will not be loaded.', entry_point.name)
  +            (root_module, _) = os.path.splitext(entry_point.module_name)
  +            content_folder_relative = os.path.join(entry_point.name, 'bundle')
  +
  +            # If it's a frontend extension only, store a list of files in the bundle directory.
  +            if resource_isdir(root_module, content_folder_relative):
  +                app.redash_extensions[entry_point.name] = {
  +                    "entry_function": None,
  +                    "resources_list": resource_listdir(root_module, content_folder_relative)
  +                }
  
verification_info: {"golden_diff": "diff --git a/redash/extensions.py b/redash/extensions.py\n--- a/redash/extensions.py\n+++ b/redash/extensions.py\n@@ -1,4 +1,5 @@\n-from pkg_resources import iter_entry_points\n+import os\n+from pkg_resources import iter_entry_points, resource_isdir, resource_listdir\n \n \n def init_extensions(app):\n@@ -10,5 +11,20 @@\n \n     for entry_point in iter_entry_points('redash.extensions'):\n         app.logger.info('Loading Redash extension %s.', entry_point.name)\n-        extension = entry_point.load()\n-        app.redash_extensions[entry_point.name] = extension(app)\n+        try:\n+            extension = entry_point.load()\n+            app.redash_extensions[entry_point.name] = {\n+                \"entry_function\": extension(app),\n+                \"resources_list\": []\n+            }\n+        except ImportError:\n+            app.logger.info('%s does not have a callable and will not be loaded.', entry_point.name)\n+            (root_module, _) = os.path.splitext(entry_point.module_name)\n+            content_folder_relative = os.path.join(entry_point.name, 'bundle')\n+\n+            # If it's a frontend extension only, store a list of files in the bundle directory.\n+            if resource_isdir(root_module, content_folder_relative):\n+                app.redash_extensions[entry_point.name] = {\n+                    \"entry_function\": None,\n+                    \"resources_list\": resource_listdir(root_module, content_folder_relative)\n+                }\n", "issue": "Add front-end extension capability\nThis is similar in concept to https://github.com/getredash/redash/pull/2354/files\n", "before_files": [{"content": "from pkg_resources import iter_entry_points\n\n\ndef init_extensions(app):\n    \"\"\"\n    Load the Redash extensions for the given Redash Flask app.\n    \"\"\"\n    if not hasattr(app, 'redash_extensions'):\n        app.redash_extensions = {}\n\n    for entry_point in iter_entry_points('redash.extensions'):\n        app.logger.info('Loading Redash extension %s.', entry_point.name)\n        extension = entry_point.load()\n        app.redash_extensions[entry_point.name] = extension(app)\n", "path": "redash/extensions.py"}], "after_files": [{"content": "import os\nfrom pkg_resources import iter_entry_points, resource_isdir, resource_listdir\n\n\ndef init_extensions(app):\n    \"\"\"\n    Load the Redash extensions for the given Redash Flask app.\n    \"\"\"\n    if not hasattr(app, 'redash_extensions'):\n        app.redash_extensions = {}\n\n    for entry_point in iter_entry_points('redash.extensions'):\n        app.logger.info('Loading Redash extension %s.', entry_point.name)\n        try:\n            extension = entry_point.load()\n            app.redash_extensions[entry_point.name] = {\n                \"entry_function\": extension(app),\n                \"resources_list\": []\n            }\n        except ImportError:\n            app.logger.info('%s does not have a callable and will not be loaded.', entry_point.name)\n            (root_module, _) = os.path.splitext(entry_point.module_name)\n            content_folder_relative = os.path.join(entry_point.name, 'bundle')\n\n            # If it's a frontend extension only, store a list of files in the bundle directory.\n            if resource_isdir(root_module, content_folder_relative):\n                app.redash_extensions[entry_point.name] = {\n                    \"entry_function\": None,\n                    \"resources_list\": resource_listdir(root_module, content_folder_relative)\n                }\n", "path": "redash/extensions.py"}]}