The favicon is currently not being displayed on pages served by my Flask app. I have the following two routes, how do I ensure the favicon is displayed?
@app.route('/')
def hello():
return redirect("tg://resolve?domain=sneakersale", code=302)
@app.route('/favicon.ico')
def fav():
return send_from_directory(os.path.join(app.root_path, 'static'),'favicon.ico')
Use the following <link>
tag to specify your favicon within your jinja2 templates. Ensure href
is set to the URL rule that you wrote in your question (/favicon.ico
)
<head>
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico">
</head>
If you're copying and pasting in the @Sean Pianka example, you might consider adding a double-quote to your href, and to differentiate, perhaps use single-quotes for items inside, like href="{{ url_for('static', filename='favicon.ico') }}"
. While href allows for unquoted values, for me, this string failed without them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With