diff --git a/example.py b/example.py index 53f7a37..351495b 100644 --- a/example.py +++ b/example.py @@ -70,4 +70,4 @@ def form(request): if __name__ == "__main__": # can also add routes like this: # app.add_route("/", index) - app.start() + app.start(blocking=True) diff --git a/spiderweb/main.py b/spiderweb/main.py index 94046ed..6039490 100644 --- a/spiderweb/main.py +++ b/spiderweb/main.py @@ -350,8 +350,6 @@ class RequestHandler(BaseHTTPRequestHandler): request.content = content self.handle_request(request) - - def get_route(self, path) -> tuple[Callable, dict[str, Any], list[str]]: for option in self._routes.keys(): if match_data := option.match(path): @@ -444,8 +442,6 @@ class RequestHandler(BaseHTTPRequestHandler): def handle_request(self, request): - request.url = urlparse.urlparse(request.path) - try: handler, additional_args, allowed_methods = self.get_route(request.url.path) except NotFound: diff --git a/spiderweb/request.py b/spiderweb/request.py index 44aec1d..5215efb 100644 --- a/spiderweb/request.py +++ b/spiderweb/request.py @@ -1,4 +1,5 @@ import json +from urllib.parse import urlparse class Request: @@ -9,7 +10,6 @@ class Request: method=None, headers=None, path=None, - url=None, query_params=None, server=None ): @@ -18,7 +18,7 @@ class Request: self.method: str = method self.headers: dict[str] = headers self.path: str = path - self.url = url + self.url = urlparse(path) self.query_params = query_params self.server = server self.GET = {}