I used the following code as shown in the video for Python.
# Uncomment this to pass the first stage
import socket
def main():
# You can use print statements as follows for debugging, they'll be visible when running tests.
print("Logs from your program will appear here!")
pong = "+PONG\r\n"
# Uncomment this to pass the first stage
#
server_socket = socket.create_server(("localhost", 6379), reuse_port=True)
conn, addr = server_socket.accept() # wait for client
with conn:
conn.recv(1024)
conn.send(pong.encode())
if __name__ == "__main__":
main()
I get the following error:
remote: [stage-2] Running tests for Stage #2: Respond to PING
remote: [stage-2] $ ./spawn_redis_server.sh
remote: [your_program] Logs from your program will appear here!
remote: [stage-2] $ redis-cli ping
remote: [stage-2] Received: "" (no content received)
remote: [stage-2] ^ error
remote: [stage-2] Error: Expected start of a new RESP value (either +, -, :, $ or *)
remote: [stage-2] Test failed (try setting 'debug: true' in your codecrafters.yml to see more details)
remote:
remote: Try our CLI to run tests faster without Git: https://codecrafters.io/cli
remote:
remote: View stage instructions: https://app.codecrafters.io/courses/redis.
remote:
To https://git.codecrafters.io/2ca2199afd4af9cb
e751b5e..f9e6861 master -> master