Nicolas Le Manchet

404 - Page Not Found

The content you are looking for probably does not exist anymore, I'm sorry about that. But since you are here, let's learn something.

How to make a creative 404 page

Start by creating a virtualenv and install flask:

$ pyvenv venv && source venv/bin/activate
(venv) $ pip install flask

Create your application, let's call it 404.py:

from flask import Flask, render_template

app = Flask(__name__)

@app.errorhandler(404)
def page_not_found(e):
    return render_template('404.html'), 404

if __name__ == "__main__":
    app.run()

The next step is about creating the actual content of the page templates/404.html. It should provide information on how to make 404 pages in your favorite language.

Run your awesome application and hit it with random requests to generate some 404s:

(venv) $ export FLASK_APP=404.py
(venv) $ flask run
 * Serving Flask app "404"
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
127.0.0.1 - - [08/Nov/2016 23:32:38] "GET /foo HTTP/1.1" 404 -
127.0.0.1 - - [08/Nov/2016 23:32:45] "GET /bar HTTP/1.1" 404 -