fix: strip query params (?__theme=...) before path routing — this was causing the 404s
Browse files
experiments/demo_server.py
CHANGED
|
@@ -566,14 +566,16 @@ class H(BaseHTTPRequestHandler):
|
|
| 566 |
self.wfile.write(body)
|
| 567 |
|
| 568 |
def do_GET(self):
|
| 569 |
-
|
|
|
|
|
|
|
| 570 |
body = PAGE.encode()
|
| 571 |
self.send_response(200)
|
| 572 |
self.send_header("Content-Type", "text/html; charset=utf-8")
|
| 573 |
self.send_header("Content-Length", str(len(body)))
|
| 574 |
self.end_headers()
|
| 575 |
self.wfile.write(body)
|
| 576 |
-
elif
|
| 577 |
self.send_response(204); self.end_headers()
|
| 578 |
else:
|
| 579 |
self.send_error(404)
|
|
|
|
| 566 |
self.wfile.write(body)
|
| 567 |
|
| 568 |
def do_GET(self):
|
| 569 |
+
# Strip query parameters (HF Spaces appends ?__theme=... etc)
|
| 570 |
+
path = self.path.split("?")[0]
|
| 571 |
+
if path in ("/", "/index.html"):
|
| 572 |
body = PAGE.encode()
|
| 573 |
self.send_response(200)
|
| 574 |
self.send_header("Content-Type", "text/html; charset=utf-8")
|
| 575 |
self.send_header("Content-Length", str(len(body)))
|
| 576 |
self.end_headers()
|
| 577 |
self.wfile.write(body)
|
| 578 |
+
elif path == "/favicon.ico":
|
| 579 |
self.send_response(204); self.end_headers()
|
| 580 |
else:
|
| 581 |
self.send_error(404)
|