def handle_not_found(exception, **extra):
assert isinstance(exception, NotFound)<EOL>page = Page.query.filter(db.or_(Page.url == request.path,<EOL>Page.url == request.path + "<STR_LIT:/>")).first()<EOL>if page:<EOL><INDENT>_add_url_rule(page.url)<EOL>return render_template(<EOL>[<EOL>page.template_name,<EOL>current_app.config['<STR_LIT>']<EOL>],<EOL>page=page<EOL>)<EOL><DEDENT>elif '<STR_LIT>' in extra:<EOL><INDENT>return extra['<STR_LIT>'](exception)<EOL><DEDENT>else:<EOL><INDENT>return exception<EOL><DEDENT>
Custom blueprint exception handler.