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