I am developing a web application using
When packaged using py2exe, my webpage does not find any images or css referenced in .html page. Basically any resource with relative path is not found
<link href="css/default.css" rel="stylesheet" type="text/css"/>
<a href="/"><img src="images/img1.gif" border="0" width="500" height="70" /></a>
I also tried to manually add these directories/files to the library.zip as well as the working directory - no luck.
from distutils.core import setup
From: David Bolen <db3l@fi...> - 2005-08-24 21:23:16
> I am developing a web application using cherrypy
> When packaged using py2exe, my webpage does not find any images or css
> referenced in .html page. Basically any resource with relative path
> is not found For example:
> <link href="css/default.css" rel="stylesheet" type="text/css"/>
> or <a href="/"><img src="images/img1.gif" border="0" width="500"
> height="70" /></a>
I'm not specifically familiar with cherrypy, but it sounds like your
problem is one of what your web server (presumably the internal one in
cherrypy) considers the "root" of its document hierarchy, and thus how
it is looking in the filesystem for relative files.
If this is something being set by your application code, could you
have a problem determining the appropriate directory in a frozen state
versus a standalone script?
Or, (glancing at the CherryPy page), depending on how you've set up
your static map, if you have supplied relative paths to the static
locations are you sure that your "current" directory when the
application is running frozen is appropriate for those relative paths?
Taking a peek into CherryPy's source, it looks like if you have a
relative static path, it attempts to use the location of the
cherrypy.root module's location (based on it's __file__) to create
absolute paths. (See cherrypy._cphttptools.serve_file)
This won't work in a frozen state since it will yield a library.zip
file, but CherryPy is then just going to try to os.stat() the
filename. You can verify this is failing by setting a "debug"
attribute in the cherrypy module which will enable some debug logging.
I have a feeling that the simplest way around this would be for you to
determine the appropriate absolute path at runtime in your own code,
and then supply absolute directory names for your static file mapping
when you initialize CherryPy, taking it's own computation out of the
picture. You can then determine the location appropriately based on
your frozen state, perhaps as in: