Beispiel #1
0
 def __init__(self,
              prefix: str,
              directory: PathLike,
              *,
              name: Optional[str] = None,
              expect_handler: Optional[_ExpectHandler] = None,
              chunk_size: int = 256 * 1024,
              show_index: bool = False,
              follow_symlinks: bool = False,
              append_version: bool = False,
              indexes: list = [],
              processors: dict = {}) -> None:
     AppLogger.__init__(self)
     StaticResource.__init__(self,
                             prefix,
                             directory,
                             name=name,
                             expect_handler=expect_handler,
                             chunk_size=chunk_size,
                             show_index=show_index,
                             follow_symlinks=follow_symlinks,
                             append_version=append_version)
     Url2File.__init__(self, directory, prefix, indexes, inherit=True)
     gr = self._routes.get('GET')
     self._routes.update({'POST': gr})
     self._routes.update({'PUT': gr})
     self._routes.update({'OPTIONS': gr})
     self._routes.update({'DELETE': gr})
     self._routes.update({'TRACE': gr})
     self.y_processors = processors
     self.y_prefix = prefix
     self.y_directory = directory
     self.y_indexes = indexes
     self.y_env = DictObject()
Beispiel #2
0
def test_static_resource_canonical() -> None:
    prefix = "/prefix"
    directory = str(pathlib.Path(aiohttp.__file__).parent)
    canonical = prefix
    res = StaticResource(prefix=prefix, directory=directory)
    assert res.canonical == canonical
Beispiel #3
0
def test_static_resource_canonical() -> None:
    prefix = '/prefix'
    directory = str(os.path.dirname(aiohttp.__file__))
    canonical = prefix
    res = StaticResource(prefix=prefix, directory=directory)
    assert res.canonical == canonical