Public Member Functions | Public Attributes | Static Public Attributes | Static Private Attributes
tornado.web.StaticFileHandler Class Reference
Inheritance diagram for tornado.web.StaticFileHandler:
Inheritance graph
[legend]

List of all members.

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 = {}

Detailed Description

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.

Definition at line 1492 of file web.py.


Member Function Documentation

def tornado.web.StaticFileHandler.get (   self,
  path,
  include_body = True 
)

Reimplemented from tornado.web.RequestHandler.

Definition at line 1528 of file web.py.

def tornado.web.StaticFileHandler.get_cache_time (   self,
  path,
  modified,
  mime_type 
)
Override to customize cache control behavior.

Return a positive number of seconds to trigger aggressive caching or 0
to mark resource as cacheable, only.

By default returns cache expiry of 10 years for resources requested
with "v" argument.

Definition at line 1593 of file web.py.

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.

Definition at line 1622 of file web.py.

def tornado.web.StaticFileHandler.head (   self,
  path 
)

Definition at line 1525 of file web.py.

def tornado.web.StaticFileHandler.initialize (   self,
  path,
  default_filename = None 
)

Definition at line 1516 of file web.py.

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.

Definition at line 1605 of file web.py.

def tornado.web.StaticFileHandler.parse_url_path (   self,
  url_path 
)
Converts a static URL path into a filesystem path.

``url_path`` is the path component of the URL with
``static_url_prefix`` removed.  The return value should be
filesystem path relative to ``static_path``.

Definition at line 1650 of file web.py.

Definition at line 1521 of file web.py.

For subclass to add extra headers to the response

Definition at line 1589 of file web.py.


Member Data Documentation

tuple tornado::web.StaticFileHandler::_lock = threading.Lock() [static, private]

Definition at line 1514 of file web.py.

dictionary tornado::web.StaticFileHandler::_static_hashes = {} [static, private]

Definition at line 1513 of file web.py.

Definition at line 1511 of file web.py.

Definition at line 1516 of file web.py.

Definition at line 1516 of file web.py.


The documentation for this class was generated from the following file:


rosbridge_server
Author(s): Jonathan Mace
autogenerated on Mon Oct 6 2014 06:58:15