Issue #1141 resolved

Cannot disable favicon.ico with single cherrypy.quickstart()

Anonymous created an issue

I'm having trouble understanding why the favicon.ico would be disabled in the latter case but not the former. {{{ import cherrypy

class Root: def index(self): return "Hello World!" index.exposed = True }}}

The following does not disable the default favicon.ico: {{{ cherrypy.quickstart(Root(), '/', config = { '/favicon.ico' : { 'tools.staticfile.on': False }}) }}} {{{ $ curl -s 127.0.0.1:8080/favicon.ico | file - /dev/stdin: MS Windows icon resource - 1 icon $ }}}

The following does disable the favicon.ico: {{{ root = Root() cherrypy.tree.mount(root, '/', config = { '/favicon.ico' : { 'tools.staticfile.on': False }}) cherrypy.quickstart() }}} {{{ $ curl -s 127.0.0.1:8080/favicon.ico
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta> <title>404 Not Found</title> ... $ }}} CherryPy version 3.2.2

Comments (2)

  1. Anonymous

    Sorry, the latter way doesn't seem to serve Root() at all.

    So, at this point I'm just wondering how do you disable the default favicon.ico?

  2. Sylvain Hellegouarch

    Don't use tree.moun and quickstart at the same time when you have a single app to server, either:

    cherrypy.quickstart(Root(), '/', config = { '/favicon.ico' : { 'tools.staticfile.on': False }})
    

    or

    cherrypy.tree.mount(Root(), '/', config = { '/favicon.ico' : { 'tools.staticfile.on': False }})
    cherrypy.engine.start()
    cherrypy.engine.block()
    

    The way you do it in your second snippet explains why it disables root entirely.

    In order to disable favicon, it's not documented and probably a bit ugly but internally the default favicon is not added through a tool but directly using the static page handler so your solution wouldn't work.

    Try simply:

    class Root(object):
        favicon_ico = None
    
    cherrypy.quickstart(Root(), '/', config = { '/favicon.ico' : { 'tools.staticfile.on': False }})
    
  3. Log in to comment