Web服务本质

code

import socket

sk = socket.socket()


sk.bind(("127.0.0.1", 8080))
sk.listen(5)

while True:
    conn, addr = sk.accept()
    data = conn.recv(8096)
    conn.send(b"HTTP/1.1 200 OK\r\n\r\n")
    conn.send(b"<h1>Hello world!</h1>")
    conn.close()

 

 

 

 

 

 

 

 

 

 

posted @ 2020-12-24 00:02  anobscureretreat  阅读(72)  评论(0编辑  收藏  举报