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 todirectory
.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 bypath
.If
directory
refers to a remote location (i.e., it starts withhttp://
orhttps://
), URLs generated viareqeust.static_url
andrequest.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.