diff --git a/sanic/handlers/directory.py b/sanic/handlers/directory.py index 56042118..b2aac758 100644 --- a/sanic/handlers/directory.py +++ b/sanic/handlers/directory.py @@ -58,7 +58,7 @@ class DirectoryHandler: @classmethod def default_handler( cls, request: Request, exception: SanicIsADirectoryError - ) -> Optional[Union[HTTPResponse, Coroutine[Any, Any, HTTPResponse]]]: + ) -> Optional[Coroutine[Any, Any, HTTPResponse]]: if exception.autoindex or exception.index_name: maybe_response = DirectoryHandler( exception.location, exception.autoindex, exception.index_name diff --git a/sanic/mixins/routes.py b/sanic/mixins/routes.py index 6b84d0d0..105d411f 100644 --- a/sanic/mixins/routes.py +++ b/sanic/mixins/routes.py @@ -27,7 +27,12 @@ from sanic.base.meta import SanicMeta from sanic.compat import stat_async from sanic.constants import DEFAULT_HTTP_CONTENT_TYPE, HTTP_METHODS from sanic.errorpages import RESPONSE_MAPPING -from sanic.exceptions import FileNotFound, HeaderNotFound, RangeNotSatisfiable +from sanic.exceptions import ( + FileNotFound, + HeaderNotFound, + RangeNotSatisfiable, + SanicIsADirectoryError, +) from sanic.handlers import ContentRangeHandler from sanic.log import error_logger from sanic.models.futures import FutureRoute, FutureStatic @@ -910,7 +915,7 @@ class RouteMixin(metaclass=SanicMeta): autoindex=autoindex, index_name=index_name, ) - except RangeNotSatisfiable: + except (RangeNotSatisfiable, SanicIsADirectoryError): raise except FileNotFoundError: raise not_found diff --git a/sanic/pages/base.py b/sanic/pages/base.py index d88d922f..b11b9c6e 100644 --- a/sanic/pages/base.py +++ b/sanic/pages/base.py @@ -27,7 +27,7 @@ class BasePage(ABC): @property def style(self) -> str: - return f"{self.BASE_STYLE}\n{self.EXTRA_STYLE}" + return self.BASE_STYLE + self.EXTRA_STYLE def render(self) -> str: self._head()