@@ -36,7 +36,10 @@ class Server:
36
36
"""A basic socket-based HTTP server."""
37
37
38
38
host : str = None
39
+ """Host name or IP address the server is listening on."""
40
+
39
41
port : int = None
42
+ """Port the server is listening on."""
40
43
41
44
def __init__ (
42
45
self , socket_source : Protocol , root_path : str = None , * , debug : bool = False
@@ -55,6 +58,8 @@ def __init__(
55
58
self ._socket_source = socket_source
56
59
self ._sock = None
57
60
self .root_path = root_path
61
+ if root_path in ["" , "/" ] and debug :
62
+ _debug_warning_exposed_files (root_path )
58
63
self .stopped = False
59
64
60
65
self .debug = debug
@@ -409,6 +414,15 @@ def socket_timeout(self, value: int) -> None:
409
414
raise ValueError ("Server.socket_timeout must be a positive numeric value." )
410
415
411
416
417
+ def _debug_warning_exposed_files (root_path : str ):
418
+ """Warns about exposing all files on the device."""
419
+ print (
420
+ f"WARNING: Setting root_path to '{ root_path } ' will expose all files on your device through"
421
+ " the webserver, including potentially sensitive files like settings.toml or secrets.py. "
422
+ "Consider making a sub-directory on your device and using that for your root_path instead."
423
+ )
424
+
425
+
412
426
def _debug_started_server (server : "Server" ):
413
427
"""Prints a message when the server starts."""
414
428
host , port = server .host , server .port
0 commit comments