python(index)

 

import socket
def handle_request(client):
    buf = client.recv(1024)
    client.send(bytes("HTTP/1.1 200 OK\r\n\r\n",encoding='utf-8'))
    #client.send(bytes("Hello, Seven",encoding='utf-8'))
    f= open('index','rb')
    data = f.read()
    f.close()
    client.send(data)
def main():
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.bind(('localhost', 8000))
    sock.listen(5)
    while True:
        connection, address = sock.accept()
        handle_request(connection)
        connection.close()
if __name__ == '__main__':
    main()

index.html

Sooele

Sooele

 
1 2 3
1 2 3

index.html

说点什么

avatar
  Subscribe  
提醒