Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 636
kino lucky Avatar asked Oct 04 '22 04:10

kino lucky


1 Answers

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)
like image 158
falsetru Avatar answered Oct 05 '22 17:10

falsetru