import socket def handle_request(client): buf=client.recv(1024) ckient.send(‘HTTP/1.1 200 OK\r\n\r\n‘) client.send(‘Hello,world‘) def main(): sock=socket.socket(socket.AF_INET,socket.SOCK_STREAM) sock.bind((‘localhhost‘,8080)) sock.listen(5) while 1: con,addr=sock.accept() handle_request(con) con.close() if __name__==‘__main__‘: main()
时间: 2024-10-12 23:32:15