| 395 | for base_url in self.route.get("urls", ("/{0}".format(api_function.__name__),)): |
| 396 | |
| 397 | def read_file(request=None, path=""): |
| 398 | filename = path.lstrip("/") |
| 399 | for directory in directories: |
| 400 | path = os.path.abspath(os.path.join(directory, filename)) |
| 401 | if not path.startswith(directory): |
| 402 | hug.redirect.not_found() |
| 403 | if os.path.isdir(path): |
| 404 | new_path = os.path.join(path, "index.html") |
| 405 | if os.path.exists(new_path) and os.path.isfile(new_path): |
| 406 | path = new_path |
| 407 | if os.path.exists(path) and os.path.isfile(path): |
| 408 | return path |
| 409 | |
| 410 | hug.redirect.not_found() |
| 411 | |
| 412 | api.http.add_sink(self._create_interface(api, read_file)[0], base_url) |
| 413 | return api_function |