You want to be able to refer to image files in your generated HTML files.
Expose the files in a directory with the following steps:
Declare a variable as an instance of class StaticDirectory.
Export the variable in _q_exports.
Then, refer to a file in the directory, for example, with <img src=...>.
Here is an example:
_q_exports = ['images_dir', ... ] from quixote.util import StaticDirectory o o o images_dir = StaticDirectory("/Quixote/myapp/images", list_directory=1)
Now you can generate HTML code that looks like the following:
<img src="/images_dir/pyfav.gif" alt="bad icon"/>
Which will look for the pyfav.gif file in the directory /Quixote/myapp/images.
The StaticDirectory constructor also responds to the following keyword arguments:
use_cache -- If use_cache is true, StaticFile instances will be cached in memory.
list_directory -- If list_directory is true, users can request a directory listing.
follow_symlinks -- If follow_symlinks is true, symbolic links will be followed.
cache_time -- Parameter cache_time indicates the number of seconds a response is considered to be valid, and will be used to set the Expires header in the response. If the value is None then the Expires header will not be set.
StaticDirectory exposes all the files in a directory. To expose a single file, use StaticFile instead.