Commit 5ef9c960 authored by codey's avatar codey
Browse files

resolves #5

parent b1d3f50d
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -43,7 +43,8 @@ class LyricSearch(FastAPI):
        self.constants = constants
        self.lyrics_engine = importlib.import_module("lyrics_engine").LyricsEngine()

        self.endpoint_name = "search"
        self.endpoint_name = "lyric_search"
        self.endpoint2_name = "lyric_cache_list"
        self.acceptable_request_sources = [
            "WEB",
            "IRC-MS",
@@ -54,7 +55,17 @@ class LyricSearch(FastAPI):
            "LIMNORIA-SHARED"
        ]

        app.add_api_route(f"/{self.endpoint_name}/",self.lyric_search_handler, methods=["POST"]) # pylint: disable=consider-using-f-string trailing-whitespace
        app.add_api_route(f"/{self.endpoint_name}/",self.lyric_search_handler, methods=["POST"])
        app.add_api_route(f"/{self.endpoint2_name}/",self.lyric_cache_list_handler, methods=["POST"]) # pylint: disable=trailing-whitespace

    async def lyric_cache_list_handler(self):
        """
        Get currently cached lyrics entries
        """
        return {
            'err': False,
            'data': await self.lyrics_engine.listCacheEntries()
        }

    async def lyric_search_handler(self, data: ValidLyricRequest):
        """
+1 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ Actionable Routes
"""

randmsg_endpoint = importlib.import_module("endpoints.rand_msg").RandMsg(app, util, constants)
# Below also provides: /lyric_cache_list/ (in addition to /lyric_search/)
lyric_search_endpoint = importlib.import_module("endpoints.lyric_search").LyricSearch(app, util, constants)