Search code examples
url-routingweb2py

How to set up favicon.ico route in local web2py


I'm testing my web2py server using the default method (python web2py.py) running on 127.0.0.1:8000, and in my routes.py file I have

routes_in=(
    (r'.*/favicon.ico',r'/myapp/static/images/favicon.ico'),
)

When I go to http://127.0.0.1:8000/myapp/static/images/favicon.ico I can see the icon, but when I go to http://127.0.0.1:8000/favicon.ico I still can't. What am I doing wrong? I've tried matching against r'.*:/favicon.ico' and various other combos too, FWIW.

Edit: The routes.py file also has the line

routers = dict(BASE=dict(default_application='myapp',),)

earlier in the file, which seems to be causing the problem.


Solution

  • As noted here, you cannot mix the parameter-based and pattern-based rewrite systems. The existence of the routers dictionary in routes.py triggers usage of the parameter-based system, so routes_in will be ignored, as it is relevant only with the pattern-based system.

    If you would like to use the parameter-based system, within routers, specify a default_application, and put the favicon.ico file in the default application's /static folder.