Skip to content

Commit

Permalink
def redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
tloriato committed May 10, 2019
1 parent f3b9123 commit 14340ed
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions Mce/abe.py
Original file line number Diff line number Diff line change
Expand Up @@ -4504,13 +4504,13 @@ def start_response(status, headers):
'QUERY_STRING': parsed.query
# MULTICHAIN START
}, start_response))
# MULTICHAIN END
# MULTICHAIN END
elif args.host or args.port:
# HTTP server.
if args.host is None:
args.host = "localhost"
from wsgiref.simple_server import make_server
# MULTICHAIN START
# MULTICHAIN START
from wsgiref import simple_server
class ExplorerWSGIServer(simple_server.WSGIServer):
# To increase the backlog
Expand Down Expand Up @@ -4538,7 +4538,7 @@ def background_catch_up():
thread.daemon = True
thread.start()
abe.log.warning("Launched background thread to catch up tx every {0} seconds".format(interval))
# MULTICHAIN END
# MULTICHAIN END
# httpd.shutdown() sometimes hangs, so don't call it. XXX
httpd.serve_forever()
else:
Expand Down Expand Up @@ -4567,6 +4567,15 @@ def watch():
Timer(interval, watch).start()
WSGIServer(abe).run()

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

def process_is_alive(pid):
# XXX probably fails spectacularly on Windows.
Expand Down

0 comments on commit 14340ed

Please sign in to comment.