kino lucky
kino lucky

Reputation: 1405

How to change the default 404 page while using python SimpleHTTPServer

When I start a http server using a command:

python -m SimpleHTTPServer

How can i change the default 404 page?

Upvotes: 5

Views: 2041

Answers (1)

falsetru
falsetru

Reputation: 369064

With command line, it is impossible.

You should make a script like following:

import BaseHTTPServer
import SimpleHTTPServer

class MyHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
    error_message_format = '''
    custom error message
    '''

BaseHTTPServer.test(MyHandler, BaseHTTPServer.HTTPServer)

Upvotes: 4

Related Questions