Simple echo server

#!/usr/bin/env python
# FILE: server.py

import socket

HOST = ''
PORT = 3000
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
    s.bind((HOST, PORT))
    s.listen(1)
    conn, addr = s.accept()
    with conn:
        print('Connected by', addr)
        while True:
            data = conn.recv(1024)
            if data == b'\n':
                break
            conn.sendall(data)

then

python server.py

and

netcat localhost 3000

to test against