favicon当前未显示在我的Flask应用程序提供的页面上。我有以下两条路由,如何确保显示favicon?
@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')
发布于 2018-07-26 15:28:34
在您的jinja2模板中使用以下<link>
标记指定您的收藏夹图标。确保将href
设置为您在问题中编写的URL规则(/favicon.ico
)
<head>
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico">
</head>
发布于 2019-11-04 20:07:07
如果您正在复制和粘贴@Sean Pianka示例,您可能会考虑在href中添加双引号,并且为了与众不同,可能会对其中的项使用单引号,如href="{{ url_for('static', filename='favicon.ico') }}"
。虽然href允许没有引号的值,但对我来说,如果没有它们,这个字符串就失败了。
https://stackoverflow.com/questions/51540800
复制