Last active
August 29, 2015 14:08
404 test handler for rust https://github.com/rust-lang/rust/issues/18498
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import BaseHTTPServer | |
from SimpleHTTPServer import SimpleHTTPRequestHandler | |
class HandlerClass(SimpleHTTPRequestHandler): | |
def do_GET(self): | |
SimpleHTTPRequestHandler.do_GET(self) | |
with open("not_found.html") as f: | |
HandlerClass.error_message_format = f.read() | |
ServerClass = BaseHTTPServer.HTTPServer | |
Protocol = "HTTP/1.0" | |
server_address = ('', 8080) | |
HandlerClass.protocol_version = Protocol | |
httpd = ServerClass(server_address, HandlerClass) | |
sa = httpd.socket.getsockname() | |
httpd.serve_forever() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am sure there is a better way to set a 404 handler in a debug server, if there is, let me know.