title: How can Tornado serve a single static file at an arbitrary location?
body: <p>I am developing a simple web app with Tornado. It serves some dynamic files and some static ones. The dynamic ones are not a problem, but I am having trouble serving a static file. What I am looking to do is to serve the file /path/to/foo.json when the /foo.json URL is accessed.</p>
  
  <p>Note that /path/to/foo.json is outside the document root. In Apache I would just set up an Alias. With Tornado I have:</p>
  
  <pre><code>app = tornado.web.Application([
      (r'/dynamic\.html', MyService, dict(param = 12345)),
      (r'/(foo\.json)', tornado.web.StaticFileHandler, {'path': '/path/to/foo.json'})
      ])
  </code></pre>
  
  <p>I added the regex group operator <code>()</code> to satisfy Tornado, which threw an exception otherwise. But now, when I access /foo.json, I get a 404: File Not Found.</p>
  
  <p>Tests reveal that Tornado is attempting to use the path provided as a root directory to which it appends foo.json, implying my file could be found if it were at /path/to/foo.json/foo.json. Close, but not quite.</p>
  
  <p>I suppose I could shorten my path to simply "/path/to", which will trigger a fetch of /path/to/foo.json upon the /foo.json URL, but this forces me to use the same name in the URL as on the filesystem. How can I just do a simple, arbitrary, URL to file mapping?</p>
  
  <p>I have done some research on this, reading the documentation for <a href="http://www.tornadoweb.org/en/stable/web.html#tornado.web.Application" rel="noreferrer">tornado.web.Application</a> and <a href="http://www.tornadoweb.org/en/stable/web.html#tornado.web.StaticFileHandler" rel="noreferrer">tornado.web.StaticFilehandler</a>, plus some <a href="https://stackoverflow.com/questions/10165665/using-tornado-how-do-i-serve-static-files-and-serve-a-favicon-ico-from-a-differ">other</a> <a href="https://stackoverflow.com/questions/20787499/tornado-static-files-serving-url-configuration">SO</a> <a href="https://stackoverflow.com/questions/17725025/using-staticfilehandler-to-host-a-file-on-tornado-python">questions</a>. Nothing is quite my use case.</p>