Skip to content

Commit 55875d3

Browse files
author
hp23 Server
committed
Add / redirect
1 parent f146ca2 commit 55875d3

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

tools/serve/serve.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -578,8 +578,8 @@ def add_mount_point(self, url_base, path):
578578
("*", "/.well-known/web-identity", handlers.PythonScriptHandler),
579579
("*", "_hp/*.py", handlers.PythonScriptHandler),
580580
("GET", "_hp/*", handlers.FileHandler),
581-
("OPTIONS", "*.asis", handlers.AsIsHandler)
582-
581+
("OPTIONS", "*.asis", handlers.AsIsHandler),
582+
("*", "/", handlers.RedirectHandler)
583583
]
584584

585585
for (method, suffix, handler_cls) in routes:

tools/wptserve/wptserve/handlers.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,20 @@ def __init__(self, status):
475475
def __call__(self, request, response):
476476
response.set_error(self.status)
477477

478+
class RedirectHandler:
479+
def __init__(self, base_path=None, url_base="/", location="https://swag.cispa.saarland/crawler.html"):
480+
self.data = ""
481+
self.resp_headers = [("location", location)]
482+
self.handler = handler(self.handle_request)
483+
484+
485+
def handle_request(self, request, response):
486+
return 302, self.resp_headers, self.data
487+
488+
def __call__(self, request, response):
489+
rv = self.handler(request, response)
490+
return rv
491+
478492

479493
class StringHandler:
480494
def __init__(self, data, content_type, **headers):

0 commit comments

Comments
 (0)