web框架 源码

 

 

import socket
def handle_request(client):
    buf=client.recv(1024)
    ckient.send('HTTP/1.1 200 OK\r\n\r\n')
    client.send('Hello,world')

def main():
    sock=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
    sock.bind(('localhhost',8080))
    sock.listen(5)

    while 1:
        con,addr=sock.accept()
        handle_request(con)
        con.close()

if __name__=='__main__':
    main()

 

posted @ 2017-04-15 14:33  ezway  阅读(290)  评论(0)    收藏  举报