prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Endpoint to return handler's icons
  At the moment we return icons for handlers by general `GET /handlers` route. Icons are return in svg or base64, which is not effective. We need new endpoint to return handler icon:
  `GET /handlers/{name}/icon/{icon_file_name}`
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `mindsdb/api/http/namespaces/handlers.py`
  Content:
  ```
  1 from flask import request
  2 from flask_restx import Resource
  3 
  4 from mindsdb.api.http.utils import http_error
  5 from mindsdb.api.http.namespaces.configs.handlers import ns_conf
  6 from mindsdb.integrations.utilities.install import install_dependencies
  7 
  8 
  9 @ns_conf.route('/')
  10 class HandlersList(Resource):
  11     @ns_conf.doc('handlers_list')
  12     def get(self):
  13         '''List all db handlers'''
  14         handlers = request.integration_controller.get_handlers_import_status()
  15         result = []
  16         for handler_type, handler_meta in handlers.items():
  17             row = {'name': handler_type}
  18             row.update(handler_meta)
  19             result.append(row)
  20         return result
  21 
  22 
  23 @ns_conf.route('/<handler_name>/install')
  24 class InstallDependencies(Resource):
  25     @ns_conf.param('handler_name', 'Handler name')
  26     def post(self, handler_name):
  27         handler_import_status = request.integration_controller.get_handlers_import_status()
  28         if handler_name not in handler_import_status:
  29             return f'Unkown handler: {handler_name}', 400
  30 
  31         if handler_import_status[handler_name].get('import', {}).get('success', False) is True:
  32             return 'Installed', 200
  33 
  34         handler_meta = handler_import_status[handler_name]
  35 
  36         dependencies = handler_meta['import']['dependencies']
  37         if len(dependencies) == 0:
  38             return 'Installed', 200
  39 
  40         result = install_dependencies(dependencies)
  41 
  42         # reload it if any result, so we can get new error message
  43         request.integration_controller.reload_handler_module(handler_name)
  44         if result.get('success') is True:
  45             return '', 200
  46         return http_error(
  47             500,
  48             'Failed to install dependency',
  49             result.get('error_message', 'unknown error')
  50         )
  51
  ```
  --- 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/mindsdb/api/http/namespaces/handlers.py b/mindsdb/api/http/namespaces/handlers.py
  --- a/mindsdb/api/http/namespaces/handlers.py
  +++ b/mindsdb/api/http/namespaces/handlers.py
  @@ -1,4 +1,8 @@
  -from flask import request
  +import os
  +import importlib
  +from pathlib import Path
  +
  +from flask import request, send_file, abort
   from flask_restx import Resource
   
   from mindsdb.api.http.utils import http_error
  @@ -20,6 +24,24 @@
           return result
   
   
  +@ns_conf.route('/<handler_name>/icon')
  +class HandlerIcon(Resource):
  +    @ns_conf.param('handler_name', 'Handler name')
  +    def get(self, handler_name):
  +        try:
  +            handlers_import_status = request.integration_controller.get_handlers_import_status()
  +            icon_name = handlers_import_status[handler_name]['icon']['name']
  +            handler_folder = handlers_import_status[handler_name]['import']['folder']
  +            mindsdb_path = Path(importlib.util.find_spec('mindsdb').origin).parent
  +            icon_path = mindsdb_path.joinpath('integrations/handlers').joinpath(handler_folder).joinpath(icon_name)
  +            if icon_path.is_absolute() is False:
  +                icon_path = Path(os.getcwd()).joinpath(icon_path)
  +        except Exception:
  +            return abort(404)
  +        else:
  +            return send_file(icon_path)
  +
  +
   @ns_conf.route('/<handler_name>/install')
   class InstallDependencies(Resource):
       @ns_conf.param('handler_name', 'Handler name')
  
verification_info: {"golden_diff": "diff --git a/mindsdb/api/http/namespaces/handlers.py b/mindsdb/api/http/namespaces/handlers.py\n--- a/mindsdb/api/http/namespaces/handlers.py\n+++ b/mindsdb/api/http/namespaces/handlers.py\n@@ -1,4 +1,8 @@\n-from flask import request\n+import os\n+import importlib\n+from pathlib import Path\n+\n+from flask import request, send_file, abort\n from flask_restx import Resource\n \n from mindsdb.api.http.utils import http_error\n@@ -20,6 +24,24 @@\n         return result\n \n \n+@ns_conf.route('/<handler_name>/icon')\n+class HandlerIcon(Resource):\n+    @ns_conf.param('handler_name', 'Handler name')\n+    def get(self, handler_name):\n+        try:\n+            handlers_import_status = request.integration_controller.get_handlers_import_status()\n+            icon_name = handlers_import_status[handler_name]['icon']['name']\n+            handler_folder = handlers_import_status[handler_name]['import']['folder']\n+            mindsdb_path = Path(importlib.util.find_spec('mindsdb').origin).parent\n+            icon_path = mindsdb_path.joinpath('integrations/handlers').joinpath(handler_folder).joinpath(icon_name)\n+            if icon_path.is_absolute() is False:\n+                icon_path = Path(os.getcwd()).joinpath(icon_path)\n+        except Exception:\n+            return abort(404)\n+        else:\n+            return send_file(icon_path)\n+\n+\n @ns_conf.route('/<handler_name>/install')\n class InstallDependencies(Resource):\n     @ns_conf.param('handler_name', 'Handler name')\n", "issue": "Endpoint to return handler's icons\nAt the moment we return icons for handlers by general `GET /handlers` route. Icons are return in svg or base64, which is not effective. We need new endpoint to return handler icon:\r\n`GET /handlers/{name}/icon/{icon_file_name}`\r\n\n", "before_files": [{"content": "from flask import request\nfrom flask_restx import Resource\n\nfrom mindsdb.api.http.utils import http_error\nfrom mindsdb.api.http.namespaces.configs.handlers import ns_conf\nfrom mindsdb.integrations.utilities.install import install_dependencies\n\n\n@ns_conf.route('/')\nclass HandlersList(Resource):\n    @ns_conf.doc('handlers_list')\n    def get(self):\n        '''List all db handlers'''\n        handlers = request.integration_controller.get_handlers_import_status()\n        result = []\n        for handler_type, handler_meta in handlers.items():\n            row = {'name': handler_type}\n            row.update(handler_meta)\n            result.append(row)\n        return result\n\n\n@ns_conf.route('/<handler_name>/install')\nclass InstallDependencies(Resource):\n    @ns_conf.param('handler_name', 'Handler name')\n    def post(self, handler_name):\n        handler_import_status = request.integration_controller.get_handlers_import_status()\n        if handler_name not in handler_import_status:\n            return f'Unkown handler: {handler_name}', 400\n\n        if handler_import_status[handler_name].get('import', {}).get('success', False) is True:\n            return 'Installed', 200\n\n        handler_meta = handler_import_status[handler_name]\n\n        dependencies = handler_meta['import']['dependencies']\n        if len(dependencies) == 0:\n            return 'Installed', 200\n\n        result = install_dependencies(dependencies)\n\n        # reload it if any result, so we can get new error message\n        request.integration_controller.reload_handler_module(handler_name)\n        if result.get('success') is True:\n            return '', 200\n        return http_error(\n            500,\n            'Failed to install dependency',\n            result.get('error_message', 'unknown error')\n        )\n", "path": "mindsdb/api/http/namespaces/handlers.py"}], "after_files": [{"content": "import os\nimport importlib\nfrom pathlib import Path\n\nfrom flask import request, send_file, abort\nfrom flask_restx import Resource\n\nfrom mindsdb.api.http.utils import http_error\nfrom mindsdb.api.http.namespaces.configs.handlers import ns_conf\nfrom mindsdb.integrations.utilities.install import install_dependencies\n\n\n@ns_conf.route('/')\nclass HandlersList(Resource):\n    @ns_conf.doc('handlers_list')\n    def get(self):\n        '''List all db handlers'''\n        handlers = request.integration_controller.get_handlers_import_status()\n        result = []\n        for handler_type, handler_meta in handlers.items():\n            row = {'name': handler_type}\n            row.update(handler_meta)\n            result.append(row)\n        return result\n\n\n@ns_conf.route('/<handler_name>/icon')\nclass HandlerIcon(Resource):\n    @ns_conf.param('handler_name', 'Handler name')\n    def get(self, handler_name):\n        try:\n            handlers_import_status = request.integration_controller.get_handlers_import_status()\n            icon_name = handlers_import_status[handler_name]['icon']['name']\n            handler_folder = handlers_import_status[handler_name]['import']['folder']\n            mindsdb_path = Path(importlib.util.find_spec('mindsdb').origin).parent\n            icon_path = mindsdb_path.joinpath('integrations/handlers').joinpath(handler_folder).joinpath(icon_name)\n            if icon_path.is_absolute() is False:\n                icon_path = Path(os.getcwd()).joinpath(icon_path)\n        except Exception:\n            return abort(404)\n        else:\n            return send_file(icon_path)\n\n\n@ns_conf.route('/<handler_name>/install')\nclass InstallDependencies(Resource):\n    @ns_conf.param('handler_name', 'Handler name')\n    def post(self, handler_name):\n        handler_import_status = request.integration_controller.get_handlers_import_status()\n        if handler_name not in handler_import_status:\n            return f'Unkown handler: {handler_name}', 400\n\n        if handler_import_status[handler_name].get('import', {}).get('success', False) is True:\n            return 'Installed', 200\n\n        handler_meta = handler_import_status[handler_name]\n\n        dependencies = handler_meta['import']['dependencies']\n        if len(dependencies) == 0:\n            return 'Installed', 200\n\n        result = install_dependencies(dependencies)\n\n        # reload it if any result, so we can get new error message\n        request.integration_controller.reload_handler_module(handler_name)\n        if result.get('success') is True:\n            return '', 200\n        return http_error(\n            500,\n            'Failed to install dependency',\n            result.get('error_message', 'unknown error')\n        )\n", "path": "mindsdb/api/http/namespaces/handlers.py"}]}