From dafc0300507a7a1780225eacba95f11a463902ad Mon Sep 17 00:00:00 2001 From: Hay1tsme Date: Thu, 9 Mar 2023 12:02:02 -0500 Subject: [PATCH] wacca: add .partition() --- titles/wacca/index.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/titles/wacca/index.py b/titles/wacca/index.py index 2a4a0cf..c922fab 100644 --- a/titles/wacca/index.py +++ b/titles/wacca/index.py @@ -94,20 +94,24 @@ class WaccaServlet: version_full = Version(req_json["appVersion"]) except: self.logger.error( - f"Failed to parse request toi {request.uri} -> {request.content.getvalue()}" + f"Failed to parse request to {url_path} -> {request.content.getvalue()}" ) resp = BaseResponse() resp.status = 1 resp.message = "不正なリクエスト エラーです" return end(resp.make()) - url_split = url_path.split("/") - start_req_idx = url_split.index("api") + 1 + if "/api/" in url_path: + func_to_find = ( + "handle_" + url_path.partition("api/")[2].replace("/", "_") + "_request" + ) - func_to_find = "handle_" - for x in range(len(url_split) - start_req_idx): - func_to_find += f"{url_split[x + start_req_idx]}_" - func_to_find += "request" + else: + self.logger.error(f"Malformed url {url_path}") + resp = BaseResponse() + resp.status = 1 + resp.message = "Bad URL" + return end(resp.make()) ver_search = int(version_full)