Problem: Validation
12
DEFAULT_RECEIVER_ENABLED = False
DEFAULT_RECEIVER_PORT = 42
if config.get('receiver_enabled', DEFAULT_RECEIVER_ENABLED):
receiver_port = config.get('receiver', {}).get('port', DEFAULT_RECEIVER_PORT)
if isinstance(receiver_port, str):
receiver_port = int(receiver_port)
elif not isinstance(receiver_port, int):
raise ValueError("sender_port not configured")
logging.info(f"receiver listening on port {sender_port}")
with TCPServer(("", PORT), SimpleHTTPRequestHandler) as httpd:
httpd.serve_forever()
Traceback (most recent call last):
File "/Users/phistep/Projects/mediaire/pycon-2024/server.py", line 8, in
with socketserver.TCPServer(("", PORT), Handler) as httpd:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/
[email protected]/3.11.7/Frameworks/Python.framework/
Versions/3.11/lib/python3.11/socketserver.py", line 456, in __init__
self.server_bind()
File "/opt/homebrew/Cellar/
[email protected]/3.11.7/Frameworks/Python.framework/
Versions/3.11/lib/python3.11/socketserver.py", line 472, in server_bind
self.socket.bind(self.server_address)
OverflowError: bind(): port must be 0-65535.