From 74c1dd808100b8e88d5c30fc2d369a15638fc4b9 Mon Sep 17 00:00:00 2001 From: Daniel Nelson Date: Sat, 1 Mar 2025 21:37:08 -0800 Subject: [PATCH] Update favicon The code sample in the existing documentation on how to redirect a favicon request assumes that add_url_rule takes a parameter named redirect_to. It does not. --- docs/patterns/favicon.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/patterns/favicon.rst b/docs/patterns/favicon.rst index 21ea767f..9f3d92d4 100644 --- a/docs/patterns/favicon.rst +++ b/docs/patterns/favicon.rst @@ -24,8 +24,10 @@ the root path of the domain you either need to configure the web server to serve the icon at the root or if you can't do that you're out of luck. If however your application is the root you can simply route a redirect:: - app.add_url_rule('/favicon.ico', - redirect_to=url_for('static', filename='favicon.ico')) + from flask import url_for + + @app.route('/favicon.ico') + return redirect( url_for( 'static', filename='favicon.ico' ) ) If you want to save the extra redirect request you can also write a view using :func:`~flask.send_from_directory`::