Skip to content

Commit b00f70f

Browse files
committed
Added validation for root_path in FileResponse
1 parent b88bfa5 commit b00f70f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

adafruit_httpserver/response.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,10 @@ def __init__( # pylint: disable=too-many-arguments
216216
)
217217
self._filename = filename + "index.html" if filename.endswith("/") else filename
218218
self._root_path = root_path or self._request.server.root_path
219+
220+
if self._root_path is None:
221+
raise ValueError("root_path must be provided in Server or in FileResponse")
222+
219223
self._full_file_path = self._combine_path(self._root_path, self._filename)
220224
self._content_type = content_type or MIMETypes.get_for_filename(self._filename)
221225
self._file_length = self._get_file_length(self._full_file_path)

0 commit comments

Comments
 (0)