From 63298bfbadbf3e0400020b31f1da718846a7b999 Mon Sep 17 00:00:00 2001 From: Temidayo32 Date: Tue, 22 Oct 2024 16:34:01 +0100 Subject: [PATCH] eliminated custom translate_path --- tests/webserver.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/tests/webserver.py b/tests/webserver.py index 3eb96a1..2a72cfe 100644 --- a/tests/webserver.py +++ b/tests/webserver.py @@ -12,16 +12,9 @@ class MyRequestHandler(SimpleHTTPRequestHandler): """Custom HTTP request handler that serves files from another directory.""" - def translate_path(self, path): - """Change working directory and translate path. - - Returns: - str: Path to web server resource - - """ - path = SimpleHTTPRequestHandler.translate_path(self, path) - rel_path = Path(path).relative_to(Path.cwd()) - return str(Path(__file__).parent / "web" / rel_path) + def __init__(self, *args, **kwargs): + self.directory = str(Path(__file__).parent / "web") + super().__init__(*args, directory=self.directory, **kwargs) class WebServer(object):