jjacobi
jjacobi

Reputation: 405

Flask 404 Catch requested url

I'm catching 404 errors on my website with this function:

@app.errorhandler(404)
def page_not_found(e):
    logger.warning('User raised an 404: {error}'.format(error=str(e)))
    return render_template('404.html'), 404

But I would like to know which url the user tried to access to raise the 404, is they a simple way to do this?

Upvotes: 7

Views: 2553

Answers (1)

Raja Simon
Raja Simon

Reputation: 10305

Use request.path to know which url tried to access and raised 404.

Upvotes: 9

Related Questions