7

the tornado server didn't do the favicon.ico by default,so i always get the info like these

[W 130626 10:38:16 web:1514] 404 GET /favicon.ico (192.168.1.57) 0.57ms

i use the web.staticfilehandler in various way include the source's example,and couldn't get it work, i got things work like this below.

handlers = [
    (r'/favicon.ico', tornado.web.StaticFileHandler,dict(url='/static/favicon.ico',permanent=False)),
    (r'/static/(.*)', tornado.web.StaticFileHandler, {"path": "plserver"}),
 ]

i felt so dump,i have to redirect it and couldn't sure it will work on web page in real world.

4

2 回答 2

14

我把它改成了这个,这次我得到了我想要的

handlers = [
    (r'/(favicon.ico)', tornado.web.StaticFileHandler, {"path": ""}),
 ]

我在写这篇文章时得到了答案。

于 2013-06-26T03:32:56.270 回答
3

我将 favicon.ico 放在 中.\static\,并将以下代码添加到 html。

<link rel="shortcut icon" href="{{ static_url('favicon.ico') }}">

它会像这样生成:

<link rel="shortcut icon" href="/static/favicon.ico?v=bb3f1">

就这样。

于 2015-12-26T14:08:29.493 回答