Solution 1
@app.route('/', defaults={'path': ''})
@app.route('/')
def catch_all(path):
print(f'recieved invalid request attempt of /{path}')
return render_template('redirect.html', reason='Unrecognised endpoint.')
Solution 2
@app.errorhandler(404)
def page_not_found(error):
return render_template('errorpage.html'), 404
app.register_error_handler(404, page_not_found)