我在将默认cherrypy favicon更改为我自己的book.ico(位于public/images/book.ico)时遇到问题。我已经尝试使用以下代码禁用它:
'/favicon.ico': {
'tools.staticfile.on': False,
}
但图标仍然显示为选项卡标签。我正在使用chrome以匿名模式浏览网站。
import cherrypy
import os
import glob
class HelloWorld(object):
favicon_ico = None
@cherrypy.expose
def index(self):
return file('public/html/index.html')
…正在跳过def generate(self,name)
if __name__ == '__main__':
cherrypy.config.update({
'server.socket_host':
'192.168.2.9','server.socket_port':8080,
'/static': {
'tools.staticdir.on': True,
'tools.staticdir.dir': os.getcwd(),
},
'/public': {
'tools.staticdir.on': True,
'tools.staticdir.dir': os.path.join(os.getcwd(), "/public"),
},
'/favicon.ico': {
'tools.staticfile.on': True,
'tools.staticfile.filename': os.path.join(os.getcwd(), '/public/images/books.ico')
}
})
cherrypy.tree.mount(HelloWorld())
cherrypy.engine.start()
cherrypy.engine.block()
目录结构
.
âââ app.conf
âââ bin
â  âââ activate
â  âââ activate.csh
â  âââ activate.fish
â  âââ activate_this.py
â  âââ cherryd
â  âââ easy_install
â  âââ easy_install-2.7
â  âââ pip
â  âââ pip2
â  âââ pip2.7
â  âââ python
â  âââ python2 -> python
â  âââ python2.7 -> python
âââ books.ico
âââ CherrypyProd.py
âââ images
âââ pip-selfcheck.json
âââ public
â  âââ css
â  âââ html
â  â  âââ books.png
â  â  âââ index.html
â  âââ images
â  âââ books.ico
â  âââ books.png
âââ ssl
âââ static
  âââ books.png
如何用我自己的books.ico替换默认的favicon.ico???
提前感谢您的帮助。如果我能进一步澄清,请告诉我。