@@ -36,7 +36,10 @@ class Server:
3636 """A basic socket-based HTTP server."""
3737
3838 host : str = None
39+ """Host name or IP address the server is listening on."""
40+
3941 port : int = None
42+ """Port the server is listening on."""
4043
4144 def __init__ (
4245 self , socket_source : Protocol , root_path : str = None , * , debug : bool = False
@@ -55,6 +58,8 @@ def __init__(
5558 self ._socket_source = socket_source
5659 self ._sock = None
5760 self .root_path = root_path
61+ if root_path in ["" , "/" ] and debug :
62+ _debug_warning_exposed_files (root_path )
5863 self .stopped = False
5964
6065 self .debug = debug
@@ -409,6 +414,15 @@ def socket_timeout(self, value: int) -> None:
409414 raise ValueError ("Server.socket_timeout must be a positive numeric value." )
410415
411416
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+
412426def _debug_started_server (server : "Server" ):
413427 """Prints a message when the server starts."""
414428 host , port = server .host , server .port
0 commit comments