paste.fileapp
– Serve files¶
This module handles sending static content such as in-memory data or files. At this time it has cache helpers and understands the if-modified-since request header.
Module Contents¶
- class paste.fileapp.FileApp(filename, headers=None, **kwargs)¶
Returns an application that will send the file at the given filename. Adds a mime type based on
mimetypes.guess_type()
. See DataApp for the arguments beyondfilename
.
- class paste.fileapp.DirectoryApp(path)¶
Returns an application that dispatches requests to corresponding FileApps based on PATH_INFO. FileApp instances are cached. This app makes sure not to serve any files that are not in a subdirectory. To customize FileApp creation override
DirectoryApp.make_fileapp
- paste.fileapp.DataApp(content, headers=None, allowed_methods=None, **kwargs)¶
Returns an application that will send content in a single chunk, this application has support for setting cache-control and for responding to conditional (or HEAD) requests.
Constructor Arguments:
content
the content being sent to the clientheaders
the headers to send /w the responseThe remaining
kwargs
correspond to headers, where the underscore is replaced with a dash. These values are only added to the headers if they are not already provided; thus, they can be used for default values. Examples include, but are not limited to:content_type
content_encoding
content_location
cache_control()
This method provides validated construction of the
Cache-Control
header as well as providing for automated filling out of theEXPIRES
header for HTTP/1.0 clients.set_content()
This method provides a mechanism to set the content after the application has been constructed. This method does things like changing
Last-Modified
andContent-Length
headers.
- paste.fileapp.ArchiveStore(filepath)¶
Returns an application that serves up a DataApp for items requested in a given zip or tar archive.
Constructor Arguments:
filepath
the path to the archive being servedcache_control()
This method provides validated construction of the
Cache-Control
header as well as providing for automated filling out of theEXPIRES
header for HTTP/1.0 clients.