Tornado StaticFileHandler path for multiple regex capture group -


from url of form: /foo/(.*)/bar/(.*) , want serve files, actual path computed 2 captured groups. problem staticfilehandler's get() takes 1 path parameter. there way work, without having reimplement of staticfilehandler's methods ?

my current workaround capture everything: (/foo/.*/bar/.*) , have reparse similar regex inside overriden get_absolute_path().

there no way without extending staticfilehandler. tiny change:

from tornado import gen, web  class customstaticfilehandler(web.staticfilehandler):      def get(self, part1, part2, include_body=true):         # mangle path         path = "dome_{}_combined_path_{}".format(part1, part2)         # staticfilehandler         return super().get(path, include_body)      # if need use coroutines on mangle use      #     # @gen.coroutine     # def get(self, part1, part2, include_body=true):     #     path = yield some_db.get_path(part1, part2)     #     yield super().get(path, include_body)  app = web.application([     (r"/foo/(.*)/bar/(.*)", customstaticfilehandler, {"path": "/tmp"}), ]) 

Comments