Skip to content
This repository has been archived by the owner on Nov 4, 2019. It is now read-only.

clokep/SimpleHTTP404Server

Repository files navigation

SimpleHTTP404Server: Easy testing of 404.html

SimpleHTTP404Server allows easy testing of static HTML providers that allow 404 response customization via a 404.html page. This includes at least GitHub and FastMail. It is a simple extension to SimpleHTTPServer, a built-in Python module which servers the current directory over HTTP.

If you server a static site using GitHub Pages or another static website provider, this module can help you test your 404 page before pushing changes to a live website.

First install the package using pip:

pip install SimpleHTTP404Server

Browse to the directory, and run the following to server it on port 8000.

python -m SimpleHTTP404Server

Or, if you'd like to specify a different port:

python -m SimpleHTTP404Server 1234

And that's it! Now browse to a page that exists, maybe http://localhost:8000/index.html. And check that your 404.html page is properly loaded by checking a few different paths:

Usecases

Personally this is used to test any GitHub Pages sites I use, in particular my blog, which is build on Pelican. This is done via Fabric:

@task
def serve():
    """Locally serve the blog."""
    local('cd {deploy_path} && python -m SimpleHTTP404Server {listen_port}'.format(**env))

Future

Please let me know (by filing issues or pull requests) if you find any bugs or if you feel there are features missing.

About

A Python SimpleHTTPServer, but serves 404.html if a page is not found.

Resources

License

Stars

Watchers

Forks

Packages

No packages published