多进程

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2018/10/31 0031 19:49
# @Author  : BWM
# @File    : 服务端.py
# @Software: PyCharm
import socketserver
class MyServer(socketserver.BaseRequestHandler):
    def handle(self):
        while 1:

            from_client_data=self.request.recv(1024).decode("utf-8")
            # name = big & pwd = 123
            # print('1111')
            # print(from_client_data,type(from_client_data))

            name_pwd=from_client_data.split("name=")
            # name = big

            print("name_pwd",name_pwd)
            name=name_pwd[1].split("&pwd=")[0]
            pwd=name_pwd[1].split("&pwd=")[1]
            print("name",name)
            print("pwd",pwd)

            if name=="big" and pwd =="123":
                self.request.send("HTTP/1.1\r\n 200 OK \r\n <h1>True</h1>".encode("utf-8"))
                print("登录成功")

if __name__ == '__main__':
    ip_port=("127.0.0.1",8888)
    socketserver.TCPServer.allow_reuse_address = True
    server = socketserver.ThreadingTCPServer(ip_port, MyServer)
    server.serve_forever()

 

posted @ 2018-11-01 15:07  Big_C  阅读(114)  评论(0编辑  收藏  举报