HTTP server, Python won't work with reusable port option solution


server_socket = socket.create_server(("localhost", 4221))
server_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
1.       while True:
2.             client_socket, addr = server_socket.accept()
3.             request = client_socket.recv(1024).decode('utf-8')
4.             http_response = (
5.                 "HTTP/1.1 200 OK\r\n"
6.                 "Content-Type: text/plain\r\n"
7.                 "Content-Length: 13\r\n"
8.                 "\r\n"
9.                 "Hello, world!\r\n"
10.             )
11.             client_socket.sendall(http_response.encode('utf-8'))
12.             client_socket.close()

What’s the issue you’re running into? What stage are you on, what do the tester logs say?

Closing due to inactivity

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.