Search code examples
htmlpathcherrypy

Unwanted / added to html file-path


I currently have a python/cherrypy application where the first page served-up is index.html, which contains the link <a href="designs.html">read more</a>

When I click on this link cherrypy returns the following traceback:

404 Not Found

The path '/designs.html' was not found.

Traceback (most recent call last): File "/home/aharrisreid/webapps/cp32/lib/python3.1/cherrypy/_cprequest.py", line 646, in respond response.body = self.handler() File "/home/aharrisreid/webapps/cp32/lib/python3.1/cherrypy/lib/encoding.py", line 188, in call self.body = self.oldhandler(*args, **kwargs) File "/home/aharrisreid/webapps/cp32/lib/python3.1/cherrypy/_cperror.py", line 387, in call raise self cherrypy._cperror.NotFound: (404, "The path '/designs.html' was not found.")

Because the href attribute is 'designs.html' I expect this page to be called directly without calling cherrypy, but somewhere along the line a / prefix has been added to designs.html, hence cherrypy has been invoked to evaluate the root path.

How can I solve this problem, and ensure that only 'designs.html' is passed to the page processor?

TIA, Alan


Solution

  • Because the href attribute is 'designs.html' I expect this page to be called directly without calling cherrypy, but somewhere along the line a / prefix has been added to designs.html, hence cherrypy has been invoked to evaluate the root path.

    I'm not sure what you mean by "directly"--something has to be invoked to evaluate any URL; if not CherryPy, what would you expect would be invoked? There's no facility for your browser to access files on the server without some form of intermediary.

    If you want to serve static files instead of dynamic content using CherryPy, check out the staticfile and staticdir Tools, described at http://docs.cherrypy.org/dev/progguide/files/static.html