Public Member Functions | |
def | get |
def | get_cache_time |
def | get_version |
def | head |
def | initialize |
def | make_static_url |
def | parse_url_path |
def | reset |
def | set_extra_headers |
Public Attributes | |
default_filename | |
root | |
Static Public Attributes | |
int | CACHE_MAX_AGE = 86400 |
Static Private Attributes | |
tuple | _lock = threading.Lock() |
dictionary | _static_hashes = {} |
A simple handler that can serve static content from a directory. To map a path to this handler for a static data directory /var/www, you would add a line to your application like:: application = web.Application([ (r"/static/(.*)", web.StaticFileHandler, {"path": "/var/www"}), ]) The local root directory of the content should be passed as the "path" argument to the handler. To support aggressive browser caching, if the argument "v" is given with the path, we set an infinite HTTP expiration header. So, if you want browsers to cache a file indefinitely, send them to, e.g., /static/images/myimage.png?v=xxx. Override ``get_cache_time`` method for more fine-grained cache control.
def tornado.web.StaticFileHandler.get | ( | self, | |
path, | |||
include_body = True |
|||
) |
Reimplemented from tornado.web.RequestHandler.
def tornado.web.StaticFileHandler.get_cache_time | ( | self, | |
path, | |||
modified, | |||
mime_type | |||
) |
def tornado.web.StaticFileHandler.get_version | ( | cls, | |
settings, | |||
path | |||
) |
Generate the version string to be used in static URLs. This method may be overridden in subclasses (but note that it is a class method rather than a static method). The default implementation uses a hash of the file's contents. ``settings`` is the `Application.settings` dictionary and ``path`` is the relative location of the requested asset on the filesystem. The returned value should be a string, or ``None`` if no version could be determined.
def tornado.web.StaticFileHandler.head | ( | self, | |
path | |||
) |
def tornado.web.StaticFileHandler.initialize | ( | self, | |
path, | |||
default_filename = None |
|||
) |
def tornado.web.StaticFileHandler.make_static_url | ( | cls, | |
settings, | |||
path | |||
) |
Constructs a versioned url for the given path. This method may be overridden in subclasses (but note that it is a class method rather than an instance method). ``settings`` is the `Application.settings` dictionary. ``path`` is the static path being requested. The url returned should be relative to the current host.
def tornado.web.StaticFileHandler.parse_url_path | ( | self, | |
url_path | |||
) |
def tornado.web.StaticFileHandler.reset | ( | cls | ) |
def tornado.web.StaticFileHandler.set_extra_headers | ( | self, | |
path | |||
) |
tuple tornado::web.StaticFileHandler::_lock = threading.Lock() [static, private] |
dictionary tornado::web.StaticFileHandler::_static_hashes = {} [static, private] |
int tornado::web.StaticFileHandler::CACHE_MAX_AGE = 86400 [static] |