static_view(root_dir, cache_max_age=3600, package_name=None, use_subpath=False)¶
An instance of this class is a callable which can act as a Pyramid view callable; this view will serve static files from a directory on disk based on the
root_diryou provide to its constructor.
The directory may contain subdirectories (recursively); the static view implementation will descend into these directories as necessary based on the components of the URL in order to resolve a path into a response.
You may pass an absolute or relative filesystem path or a asset specification representing the directory containing static files as the
root_dirargument to this class’ constructor.
root_dirpath is relative, and the
root_dirwill be considered relative to the directory in which the Python file which calls
staticresides. If the
package_namename argument is provided, and a relative
root_diris provided, the
root_dirwill be considered relative to the Python package specified by
package_name(a dotted path to a Python package).
Max-Ageresponse headers returned by the view (default is 3600 seconds or five minutes).
request.subpathwill be used as
PATH_INFOwhen calling the underlying WSGI application which actually serves the static files. If it is
True, the static application will consider
PATH_INFOinput. If it is
False, the static application will consider request.path_info as
PATH_INFOinput. By default, this is
root_diris relative to a package, or is a asset specification the Pyramid
pyramid.config.Configuratormethod can be used to override assets within the named
root_dirpackage-relative directory. However, if the
root_diris absolute, configuration will not be able to override the assets it contains.