1.第一次提交
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
venv
|
||||
20
main.py
Normal file
20
main.py
Normal file
@@ -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()
|
||||
Reference in New Issue
Block a user