CherryPy provides two simple tools to serve either a single file or an entire directory. In either case CherryPy takes care of the HTTP caching aspect of your static resource by automatically checking the presence of the If-Modified-Since
and If-Unmodified-Since
headers in the request and returning directly the 304 Not Modified
response, if that's the case.
The staticfile
tool can be used to serve a single file.
Arguments:
Name |
Default |
Description |
---|---|---|
|
N/A |
Absolute or relative path to the physical file. |
|
None |
If filename is relative you must provide the root directory of the file. |
|
"" |
Regular expression to check that the URI path matches a certain pattern. |
|
None |
Dictionary of the form |
Example:
For this purpose let's imagine we have the following directory layout:
application \ myapp.py design1.css
design1.css
is set as follows:
body { background-color...