Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flask 404 Catch requested url

Tags:

flask

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?

like image 464
jjacobi Avatar asked May 15 '18 09:05

jjacobi


1 Answers

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

like image 194
Raja Simon Avatar answered Oct 12 '22 23:10

Raja Simon