14
14
# License for the specific language governing permissions and limitations
15
15
# under the License.
16
16
17
- """The Tornado web framework.
18
-
17
+ """
19
18
The Tornado web framework looks a bit like web.py (http://webpy.org/) or
20
19
Google's webapp (http://code.google.com/appengine/docs/python/tools/webapp/),
21
20
but with additional tools and optimizations to take advantage of the
22
21
Tornado non-blocking web server and tools.
23
22
24
- Here is the canonical "Hello, world" example app:
23
+ Here is the canonical "Hello, world" example app::
25
24
26
25
import tornado.ioloop
27
26
import tornado.web
@@ -40,7 +39,8 @@ def get(self):
40
39
See the Tornado walkthrough on http://tornadoweb.org for more details
41
40
and a good getting started guide.
42
41
43
- Thread-safety notes:
42
+ Thread-safety notes
43
+ -------------------
44
44
45
45
In general, methods on RequestHandler and elsewhere in tornado are not
46
46
thread-safe. In particular, methods such as write(), finish(), and
@@ -120,7 +120,7 @@ def initialize(self):
120
120
A dictionary passed as the third argument of a url spec will be
121
121
supplied as keyword arguments to initialize().
122
122
123
- Example:
123
+ Example::
124
124
class ProfileHandler(RequestHandler):
125
125
def initialize(self, database):
126
126
self.database = database
@@ -984,7 +984,7 @@ def asynchronous(method):
984
984
If this decorator is given, the response is not finished when the
985
985
method returns. It is up to the request handler to call self.finish()
986
986
to finish the HTTP request. Without this decorator, the request is
987
- automatically finished when the get() or post() method returns.
987
+ automatically finished when the get() or post() method returns. ::
988
988
989
989
class MyRequestHandler(web.RequestHandler):
990
990
@web.asynchronous
@@ -1009,9 +1009,9 @@ def wrapper(self, *args, **kwargs):
1009
1009
def removeslash (method ):
1010
1010
"""Use this decorator to remove trailing slashes from the request path.
1011
1011
1012
- For example, a request to '/foo/' would redirect to '/foo' with this
1012
+ For example, a request to `` '/foo/'`` would redirect to `` '/foo'`` with this
1013
1013
decorator. Your request handler mapping should use a regular expression
1014
- like r'/foo/*' in conjunction with using the decorator.
1014
+ like `` r'/foo/*'`` in conjunction with using the decorator.
1015
1015
"""
1016
1016
@functools .wraps (method )
1017
1017
def wrapper (self , * args , ** kwargs ):
@@ -1052,7 +1052,7 @@ class Application(object):
1052
1052
"""A collection of request handlers that make up a web application.
1053
1053
1054
1054
Instances of this class are callable and can be passed directly to
1055
- HTTPServer to serve the application:
1055
+ HTTPServer to serve the application::
1056
1056
1057
1057
application = web.Application([
1058
1058
(r"/", MainPageHandler),
@@ -1069,14 +1069,14 @@ class Application(object):
1069
1069
Each tuple can contain an optional third element, which should be a
1070
1070
dictionary if it is present. That dictionary is passed as keyword
1071
1071
arguments to the contructor of the handler. This pattern is used
1072
- for the StaticFileHandler below:
1072
+ for the StaticFileHandler below::
1073
1073
1074
1074
application = web.Application([
1075
1075
(r"/static/(.*)", web.StaticFileHandler, {"path": "/var/www"}),
1076
1076
])
1077
1077
1078
1078
We support virtual hosts with the add_handlers method, which takes in
1079
- a host regular expression as the first argument:
1079
+ a host regular expression as the first argument::
1080
1080
1081
1081
application.add_handlers(r"www\.myhost\.com", [
1082
1082
(r"/article/([0-9]+)", ArticleHandler),
@@ -1333,7 +1333,7 @@ def prepare(self):
1333
1333
class RedirectHandler (RequestHandler ):
1334
1334
"""Redirects the client to the given URL for all GET requests.
1335
1335
1336
- You should provide the keyword argument "url" to the handler, e.g.:
1336
+ You should provide the keyword argument "url" to the handler, e.g.::
1337
1337
1338
1338
application = web.Application([
1339
1339
(r"/oldpath", web.RedirectHandler, {"url": "/newpath"}),
@@ -1351,7 +1351,7 @@ class StaticFileHandler(RequestHandler):
1351
1351
"""A simple handler that can serve static content from a directory.
1352
1352
1353
1353
To map a path to this handler for a static data directory /var/www,
1354
- you would add a line to your application like:
1354
+ you would add a line to your application like::
1355
1355
1356
1356
application = web.Application([
1357
1357
(r"/static/(.*)", web.StaticFileHandler, {"path": "/var/www"}),
@@ -1438,7 +1438,8 @@ class FallbackHandler(RequestHandler):
1438
1438
The fallback is a callable object that accepts an HTTPRequest,
1439
1439
such as an Application or tornado.wsgi.WSGIContainer. This is most
1440
1440
useful to use both tornado RequestHandlers and WSGI in the same server.
1441
- Typical usage:
1441
+ Typical usage::
1442
+
1442
1443
wsgi_app = tornado.wsgi.WSGIContainer(
1443
1444
django.core.handlers.wsgi.WSGIHandler())
1444
1445
application = tornado.web.Application([
0 commit comments