🎨 clean up a bit

This commit is contained in:
Joe Kaufeld 2024-08-14 20:12:11 -04:00
parent ecf11bcefe
commit dc5c57d835
3 changed files with 3 additions and 7 deletions

View File

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

View File

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

View File

@ -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 = {}