Fix 404 on /?key=… (route matching must strip the query string)
This commit is contained in:
@@ -29,6 +29,7 @@ import time
|
|||||||
import uuid
|
import uuid
|
||||||
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
# Config
|
# Config
|
||||||
@@ -212,10 +213,11 @@ class Handler(BaseHTTPRequestHandler):
|
|||||||
# -- routes -----------------------------------------------------------
|
# -- routes -----------------------------------------------------------
|
||||||
|
|
||||||
def do_GET(self):
|
def do_GET(self):
|
||||||
if self.path in ("/", "/index.html"):
|
path = urlparse(self.path).path # strip ?query so /?key=… still routes
|
||||||
|
if path in ("/", "/index.html"):
|
||||||
self._send(200, PAGE.encode(), "text/html; charset=utf-8")
|
self._send(200, PAGE.encode(), "text/html; charset=utf-8")
|
||||||
return
|
return
|
||||||
if self.path == "/file":
|
if path == "/file":
|
||||||
if not self._authorized():
|
if not self._authorized():
|
||||||
self._json(401, {"error": "token required"})
|
self._json(401, {"error": "token required"})
|
||||||
return
|
return
|
||||||
@@ -228,7 +230,7 @@ class Handler(BaseHTTPRequestHandler):
|
|||||||
"head": git_head(), "repo": str(REPO),
|
"head": git_head(), "repo": str(REPO),
|
||||||
"sections": parse_sections(content)})
|
"sections": parse_sections(content)})
|
||||||
return
|
return
|
||||||
if self.path.startswith("/job/"):
|
if path.startswith("/job/"):
|
||||||
if not self._authorized():
|
if not self._authorized():
|
||||||
self._json(401, {"error": "token required"})
|
self._json(401, {"error": "token required"})
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user