import socket
phone = socket.socket()
phone.bind(('127.0.0.1',9999))
phone.listen(3)
while 1:
    conn,addr = phone.accept()
    ret = conn.recv(1024)
    print(ret.decode("utf-8")) 
    send_msg = b'HTTP/1.1 200 ok\r\n\r\n'     #发送信息要加上http头
    # conn.send(send_msg+"hello".encode("utf-8"))
    with open("msg.html","rb") as f:
        msg = f.read()
    conn.send(send_msg+msg)
    conn.close()
phone.close()
socket开启服务

相关文章:

  • 2022-12-23
  • 2021-05-27
  • 2021-07-06
  • 2022-12-23
  • 2022-12-23
  • 2021-11-16
  • 2022-02-19
  • 2022-01-29
猜你喜欢
  • 2022-01-16
  • 2022-02-19
  • 2022-12-23
  • 2021-11-25
  • 2021-12-06
  • 2022-12-23
  • 2021-08-06
相关资源
相似解决方案