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

List of all members.

Public Member Functions

def __call__
def __init__
def add_handlers
def add_transform
def listen
def log_request
def reverse_url
def start_request

Public Attributes

 default_host
 handlers
 named_handlers
 settings
 transforms
 ui_methods
 ui_modules

Private Member Functions

def _get_host_handlers
def _load_ui_methods
def _load_ui_modules

Detailed Description

A collection of request handlers that make up a web application.

Instances of this class are callable and can be passed directly to
HTTPServer to serve the application::

    application = web.Application([
        (r"/", MainPageHandler),
    ])
    http_server = httpserver.HTTPServer(application)
    http_server.listen(8080)
    ioloop.IOLoop.instance().start()

The constructor for this class takes in a list of `URLSpec` objects
or (regexp, request_class) tuples. When we receive requests, we
iterate over the list in order and instantiate an instance of the
first request class whose regexp matches the request path.
The request class can be specified as either a class object or a
(fully-qualified) name.

Each tuple can contain additional elements, which correspond to the
arguments to the `URLSpec` constructor.  (Prior to Tornado 3.2, this
only tuples of two or three elements were allowed).

A dictionary may be passed as the third element of the tuple,
which will be used as keyword arguments to the handler's
constructor and `~RequestHandler.initialize` method.  This pattern
is used for the `StaticFileHandler` in this example (note that a
`StaticFileHandler` can be installed automatically with the
static_path setting described below)::

    application = web.Application([
        (r"/static/(.*)", web.StaticFileHandler, {"path": "/var/www"}),
    ])

We support virtual hosts with the `add_handlers` method, which takes in
a host regular expression as the first argument::

    application.add_handlers(r"www\.myhost\.com", [
        (r"/article/([0-9]+)", ArticleHandler),
    ])

You can serve static files by sending the ``static_path`` setting
as a keyword argument. We will serve those files from the
``/static/`` URI (this is configurable with the
``static_url_prefix`` setting), and we will serve ``/favicon.ico``
and ``/robots.txt`` from the same directory.  A custom subclass of
`StaticFileHandler` can be specified with the
``static_handler_class`` setting.

Definition at line 1576 of file web.py.


Constructor & Destructor Documentation

def tornado.web.Application.__init__ (   self,
  handlers = None,
  default_host = "",
  transforms = None,
  settings 
)

Definition at line 1627 of file web.py.


Member Function Documentation

def tornado.web.Application.__call__ (   self,
  request 
)

Definition at line 1773 of file web.py.

def tornado.web.Application._get_host_handlers (   self,
  request 
) [private]

Definition at line 1727 of file web.py.

def tornado.web.Application._load_ui_methods (   self,
  methods 
) [private]

Definition at line 1740 of file web.py.

def tornado.web.Application._load_ui_modules (   self,
  modules 
) [private]

Definition at line 1753 of file web.py.

def tornado.web.Application.add_handlers (   self,
  host_pattern,
  host_handlers 
)
Appends the given handlers to our handler list.

Host patterns are processed sequentially in the order they were
added. All matching patterns will be considered.

Definition at line 1693 of file web.py.

def tornado.web.Application.add_transform (   self,
  transform_class 
)

Definition at line 1724 of file web.py.

def tornado.web.Application.listen (   self,
  port,
  address = "",
  kwargs 
)
Starts an HTTP server for this application on the given port.

This is a convenience alias for creating an `.HTTPServer`
object and calling its listen method.  Keyword arguments not
supported by `HTTPServer.listen <.TCPServer.listen>` are passed to the
`.HTTPServer` constructor.  For advanced uses
(e.g. multi-process mode), do not use this method; create an
`.HTTPServer` and call its
`.TCPServer.bind`/`.TCPServer.start` methods directly.

Note that after calling this method you still need to call
``IOLoop.instance().start()`` to start the server.

Definition at line 1673 of file web.py.

def tornado.web.Application.log_request (   self,
  handler 
)
Writes a completed HTTP request to the logs.

By default writes to the python root logger.  To change
this behavior either subclass Application and override this method,
or pass a function in the application settings dictionary as
``log_function``.

Definition at line 1792 of file web.py.

def tornado.web.Application.reverse_url (   self,
  name,
  args 
)
Returns a URL path for handler named ``name``

The handler must be added to the application as a named `URLSpec`.

Args will be substituted for capturing groups in the `URLSpec` regex.
They will be converted to strings if necessary, encoded as utf8,
and url-escaped.

Definition at line 1779 of file web.py.

def tornado.web.Application.start_request (   self,
  connection 
)

Definition at line 1769 of file web.py.


Member Data Documentation

Definition at line 1627 of file web.py.

Definition at line 1627 of file web.py.

Definition at line 1627 of file web.py.

Definition at line 1627 of file web.py.

Definition at line 1627 of file web.py.

Definition at line 1627 of file web.py.

Definition at line 1627 of file web.py.


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


rosbridge_server
Author(s): Jonathan Mace
autogenerated on Thu Jun 6 2019 21:51:51