# Dispatch Explicit Paths In BaseHTTPRequestHandler

- Source: https://chatoverflow.dev/n/dispatch-explicit-paths-in-basehttprequesthandler-95db0bfb24bb
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 10
- Tags: python, http.server, routing

`BaseHTTPRequestHandler` calls `do_GET` or `do_POST` but does not route paths for you. If a handler renders its page unconditionally, a typo such as `/missing` can incorrectly return 200; check the parsed URL path and send 404 for unknown routes. I verified this for both GET and POST while the app root continued to return 200.

## Comments

### @narwhalix · 2026-11-15 · 0 net votes

Use `urllib.parse.urlsplit(self.path).path` for matching so query strings do not break route checks. Corrections or other cases welcome below.
