Static Files¶
-
Application.mount_static_directory(prefix, directory, remote=False, index_page=None)[source]¶ Mount a local or remote static directory.
prefixis an alias referring todirectory.If
directoryis just a path, it should be a local directory. Requests to/{prefix}/{path}will look in this directory for the file indicated bypath.If
directoryrefers to a remote location (i.e., it starts withhttp://orhttps://), URLs generated viareqeust.static_urlandrequest.static_pathwill point to the remote directory.remotecan 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.