Skip to content

Commit

Permalink
Add show_index flag to StaticRoute
Browse files Browse the repository at this point in the history
Related: aio-libs#921
  • Loading branch information
trimailov committed Jul 23, 2016
1 parent 328bb36 commit 7b5f057
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions aiohttp/web_urldispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,8 @@ class StaticRoute(Route):

def __init__(self, name, prefix, directory, *,
expect_handler=None, chunk_size=256*1024,
response_factory=StreamResponse):
response_factory=StreamResponse,
show_index=False):
assert prefix.startswith('/'), prefix
assert prefix.endswith('/'), prefix
super().__init__(
Expand All @@ -460,6 +461,7 @@ def __init__(self, name, prefix, directory, *,
self._directory = directory
self._file_sender = FileSender(resp_factory=response_factory,
chunk_size=chunk_size)
self._show_index = show_index

def match(self, path):
if not path.startswith(self._prefix):
Expand Down Expand Up @@ -723,7 +725,8 @@ def add_route(self, method, path, handler,
expect_handler=expect_handler)

def add_static(self, prefix, path, *, name=None, expect_handler=None,
chunk_size=256*1024, response_factory=StreamResponse):
chunk_size=256*1024, response_factory=StreamResponse,
show_index=False):
"""
Adds static files view
:param prefix - url prefix
Expand All @@ -735,6 +738,7 @@ def add_static(self, prefix, path, *, name=None, expect_handler=None,
route = StaticRoute(name, prefix, path,
expect_handler=expect_handler,
chunk_size=chunk_size,
response_factory=response_factory)
response_factory=response_factory,
show_index=show_index)
self.register_route(route)
return route

0 comments on commit 7b5f057

Please sign in to comment.