]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Document how to fake other root files despite serving with StaticFileHandler
authorAlan Hogan <contact@alanhogan.com>
Sun, 15 May 2011 19:05:13 +0000 (12:05 -0700)
committerAlan Hogan <contact@alanhogan.com>
Sun, 15 May 2011 19:05:13 +0000 (12:05 -0700)
website/templates/documentation.txt

index 746c4974279a89432f0a9520de2bfc2af9462587..d68f378d848a902f64228833f1d4028b74134346 100644 (file)
@@ -521,6 +521,7 @@ setting in your application:
     application = tornado.web.Application([
         (r"/", MainHandler),
         (r"/login", LoginHandler),
+        (r"/(apple-touch-icon(?:-precomposed)?\.png)", tornado.web.StaticFileHandler,
     ], **settings)
 
 This setting will automatically make all requests that start with `/static/`
@@ -529,6 +530,12 @@ will serve the file `foo.png` from the specified static directory. We
 also automatically serve `/robots.txt` and `/favicon.ico` from the static
 directory (even though they don't start with the `/static/` prefix).
 
+In the above settings, we have explicitly configured Tornado to serve `apple-touch-icon.png`
+“from” the root with the `StaticFileHandler`, though it is physically in the static file directory.
+You could do the same thing to serve e.g. `sitemap.xml` from the site root.
+Of course, you can also avoid faking a root `apple-touche-icon.png`
+by using the appropriate `<link />` tag in your HTML.
+
 To improve performance, it is generally a good idea for browsers to
 cache static resources aggressively so browsers won't send unnecessary
 `If-Modified-Since` or `Etag` requests that might block the rendering of