From 5ef9c960df38917c894b795f7f570193a8799e01 Mon Sep 17 00:00:00 2001 From: codey Date: Sun, 11 Aug 2024 17:04:06 -0400 Subject: [PATCH] resolves #5 --- endpoints/lyric_search.py | 15 +++++++++++++-- main.py | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/endpoints/lyric_search.py b/endpoints/lyric_search.py index 7f6b8a9..2f18f5d 100644 --- a/endpoints/lyric_search.py +++ b/endpoints/lyric_search.py @@ -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): """ diff --git a/main.py b/main.py index aff1fee..6841397 100644 --- a/main.py +++ b/main.py @@ -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)