Skip to content

Commit 0607776

Browse files
committed
Added host and port attributes to Server
1 parent e1d3e3b commit 0607776

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

adafruit_httpserver/server.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
class Server:
3535
"""A basic socket-based HTTP server."""
3636

37+
host: str = None
38+
port: int = None
39+
3740
def __init__(self, socket_source: Protocol, root_path: str = None) -> None:
3841
"""Create a server, and get it ready to run.
3942
@@ -129,6 +132,8 @@ def start(self, host: str, port: int = 80) -> None:
129132
"""
130133
self._verify_can_start(host, port)
131134

135+
self.host, self.port = host, port
136+
132137
self.stopped = False
133138
self._sock = self._socket_source.socket(
134139
self._socket_source.AF_INET, self._socket_source.SOCK_STREAM
@@ -143,6 +148,8 @@ def stop(self) -> None:
143148
Current requests will be processed. Server can be started again by calling ``.start()``
144149
or ``.serve_forever()``.
145150
"""
151+
self.host, self.port = None, None
152+
146153
self.stopped = True
147154
self._sock.close()
148155

0 commit comments

Comments
 (0)