Skip to content

Commit 14340ed

Browse files
committed
def redirect
1 parent f3b9123 commit 14340ed

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

Mce/abe.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4504,13 +4504,13 @@ def start_response(status, headers):
45044504
'QUERY_STRING': parsed.query
45054505
# MULTICHAIN START
45064506
}, start_response))
4507-
# MULTICHAIN END
4507+
# MULTICHAIN END
45084508
elif args.host or args.port:
45094509
# HTTP server.
45104510
if args.host is None:
45114511
args.host = "localhost"
45124512
from wsgiref.simple_server import make_server
4513-
# MULTICHAIN START
4513+
# MULTICHAIN START
45144514
from wsgiref import simple_server
45154515
class ExplorerWSGIServer(simple_server.WSGIServer):
45164516
# To increase the backlog
@@ -4538,7 +4538,7 @@ def background_catch_up():
45384538
thread.daemon = True
45394539
thread.start()
45404540
abe.log.warning("Launched background thread to catch up tx every {0} seconds".format(interval))
4541-
# MULTICHAIN END
4541+
# MULTICHAIN END
45424542
# httpd.shutdown() sometimes hangs, so don't call it. XXX
45434543
httpd.serve_forever()
45444544
else:
@@ -4567,6 +4567,15 @@ def watch():
45674567
Timer(interval, watch).start()
45684568
WSGIServer(abe).run()
45694569

4570+
def redirect(page):
4571+
uri = wsgiref.util.request_uri(page['env'])
4572+
page['start_response'](
4573+
'301 Moved Permanently',
4574+
[('Location', str(uri)),
4575+
('Content-Type', 'text/html')])
4576+
return ('<html><head><title>Moved</title></head>\n'
4577+
'<body><h1>Moved</h1><p>This page has moved to '
4578+
'<a href="' + uri + '">' + uri + '</a></body></html>')
45704579

45714580
def process_is_alive(pid):
45724581
# XXX probably fails spectacularly on Windows.

0 commit comments

Comments
 (0)