(This is on a Windows filesystem)
Say that I have the following htdocs dir structure:
c:\abc\htdocs
index.html
picture.jpg
\js
somescript.js
and my index.html looks like this:
<html>
<head>
<title>Apache vs Cherrypy Test</title>
<script type="text/javascript" src="/js/somescript.js"></script>
</head>
<body>
<img src='/picture.jpg' />
</body>
</html>
With Apache, I just point my httpd.conf's DocumentRoot to c:\abc\htdocs and my index.html can access /picture.jpg and /js/somescript.js with no special configs.
Put another way, my HTML can reference relative URLs with no custom server config.
Now switch to cherrypy land.
I'm able to get cherrypy to serve my index.html, but get 404's on the .jpg and .js files
Is there some way to cause cherrypy to simply serve up ANY htdocs-relative requested file (e.g. /picture.jpg and/or /js/somescript.js) without needing to create explicit config entries for each file and/or htdocs subdir?
I'd have expected to be able to create a simple config like this:
[/]
tools.staticfile.root = "c:\abc\htdocs"
which would then allow access to /picture.jpg and /js/somescript.js, but that doesn't work.
Is there a simple way to instruct cherrypy serve up "wildcard" relative URLs w/o needing to provide file-specific entries in the config?
staticfile is for individual files one at a time. Try staticdir instead. See http://docs.cherrypy.org/dev/refman/lib/static.html#cherrypy.lib.static.staticdir for the config params it can take. I highly recommend setting "tools.staticdir.debug = True" while you poke around. See also http://docs.cherrypy.org/dev/progguide/files/static.html#serving-files-through-the-staticdir-tool for some prose about using it.