This commit is contained in:
codey 2024-08-11 17:04:06 -04:00
parent b1d3f50df2
commit 5ef9c960df
2 changed files with 14 additions and 2 deletions

View File

@ -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):
"""

View File

@ -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)