| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import os | 5 import os |
| 6 | 6 |
| 7 from future import Future | 7 from future import Future |
| 8 | 8 |
| 9 class _Response(object): | 9 class _Response(object): |
| 10 def __init__(self): | 10 def __init__(self): |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 if filename.startswith('.'): | 31 if filename.startswith('.'): |
| 32 continue | 32 continue |
| 33 if os.path.isdir(os.path.join(self._base_path, directory, filename)): | 33 if os.path.isdir(os.path.join(self._base_path, directory, filename)): |
| 34 html += '<a>' + filename + '/</a>\n' | 34 html += '<a>' + filename + '/</a>\n' |
| 35 else: | 35 else: |
| 36 html += '<a>' + filename + '</a>\n' | 36 html += '<a>' + filename + '</a>\n' |
| 37 html += '</html>' | 37 html += '</html>' |
| 38 return html | 38 return html |
| 39 | 39 |
| 40 def FetchAsync(self, url): | 40 def FetchAsync(self, url): |
| 41 url = url.rsplit('?', 1)[0] |
| 41 return Future(value=self.Fetch(url)) | 42 return Future(value=self.Fetch(url)) |
| 42 | 43 |
| 43 def Fetch(self, url): | 44 def Fetch(self, url): |
| 45 url = url.rsplit('?', 1)[0] |
| 44 result = _Response() | 46 result = _Response() |
| 45 if url.endswith('/'): | 47 if url.endswith('/'): |
| 46 result.content = self._ListDir(url) | 48 result.content = self._ListDir(url) |
| 47 else: | 49 else: |
| 48 result.content = self._ReadFile(url) | 50 result.content = self._ReadFile(url) |
| 49 return result | 51 return result |
| OLD | NEW |