标签:nec span http blog and logs oca png his
python 3 案例写法
web框架的本质 socket
import socket def handle_request(client): buf = client.recv(1024) client.send("HTTP/1.1 200 OK\r\n\r\n".encode(‘utf-8‘)) client.send("<h1 style=‘color:red‘>Hello, World send This is and me python project</h1>".encode(‘utf-8‘)) def main(): sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.bind((‘localhost‘,8000)) sock.listen(5) while True: connection, address = sock.accept() print(connection, address) handle_request(connection) connection.close() if __name__ == ‘__main__‘: main()
网站显示:
标签:nec span http blog and logs oca png his
原文地址:http://www.cnblogs.com/Mjonj/p/7676962.html