Static Files

Application.mount_static_directory(prefix, directory, remote=False, index_page=None)[source]

Mount a local or remote static directory.

prefix is an alias referring to directory.

If directory is just a path, it should be a local directory. Requests to /{prefix}/{path} will look in this directory for the file indicated by path.

If directory refers to a remote location (i.e., it starts with http:// or https://), URLs generated via reqeust.static_url and request.static_path will point to the remote directory.

remote can also be specified explicitly. In this context, “remote” means not served by the application itself. E.g., you might be mapping an alias in Nginx to a local directory.

Note

It’s best to always use tangled.web.request.Request.static_url() tangled.web.request.Request.static_path() to generate static URLs.