【问题标题】:how to get favicon.ico work on tornado如何让 favicon.ico 在龙卷风上工作
【发布时间】:2013-06-26 03:32:56
【问题描述】:

tornado 服务器默认不做 favicon.ico,所以我总是得到这样的信息

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

我以各种方式使用 web.staticfilehandler,包括源代码的示例,但无法使其工作,我得到了如下所示的工作。

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

我觉得很垃圾,我必须重定向它,但不确定它是否能在现实世界中的网页上运行。

【问题讨论】:

    标签: python-3.x tornado


    【解决方案1】:

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

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

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

    【讨论】:

      【解决方案2】:

      我把favicon.ico放在.\static\中,并在html中添加如下代码。

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

      它会像这样生成:

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

      就是这样。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-03-05
        • 2011-10-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-05-23
        • 2015-05-01
        相关资源
        最近更新 更多