import socket
#网络连接模块,模拟浏览器过程
def headle_requests(conn):
conn.recv(1024)#等待接收
conn.sendall(bytes("HTTP/1.1 201 OK ",encoding="utf-8"))
conn.sendall(bytes("test.html",encoding="utf-8"))
def main():
sk = socket.socket()
sk.bind(("localhost",9000))
sk.listen(5)#监听5
while True:
conn,address = sk.accept()#阻塞等待来练
headle_requests(conn)
conn.close()
if __name__ == '__main__':
main()