1.第一次提交
This commit is contained in:
commit
8ff97d2a65
|
|
@ -0,0 +1 @@
|
|||
venv
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
from socketserver import BaseRequestHandler, TCPServer
|
||||
|
||||
|
||||
class EchoHandler(BaseRequestHandler):
|
||||
def handle(self):
|
||||
print("Got connection from", self.client_address)
|
||||
host=self.request.recv(1024)
|
||||
print("Host is {host}".format(host=host))
|
||||
if host:
|
||||
if host=='bwg'.encode('ascii'):
|
||||
self.request.sendall("50%\n".encode('ascii'))
|
||||
print('send to bwg')
|
||||
if host=='hosteons'.encode('ascii'):
|
||||
self.request.sendall("80%\n".encode('ascii'))
|
||||
self.request.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
serv = TCPServer(("", 20000), EchoHandler)
|
||||
serv.serve_forever()
|
||||
Loading…
Reference in New Issue