web服务的本质
import socket def main(): sock=socket.socket(socket.AF_INET,sock.SOCK_STREAM) sock.blind(('localhost',8081)) sock.listen(5) while True: print(''server is working......'') conn,address=sock.accpt() request=conn.recv(1024) conn.sendall(bytes(''HTTP/1.1 201 ok\r\n<h1>hello welcome to html</h1>'',utf-8)) conn.close() if __name__=='__main__' : main()