1.添加数据支持。
This commit is contained in:
parent
e20940de1f
commit
6204d44c8b
15
main.py
15
main.py
|
|
@ -1,4 +1,5 @@
|
||||||
from socketserver import BaseRequestHandler, TCPServer
|
from socketserver import BaseRequestHandler, TCPServer
|
||||||
|
import db
|
||||||
|
|
||||||
|
|
||||||
class EchoHandler(BaseRequestHandler):
|
class EchoHandler(BaseRequestHandler):
|
||||||
|
|
@ -7,11 +8,15 @@ class EchoHandler(BaseRequestHandler):
|
||||||
host = self.request.recv(1024)
|
host = self.request.recv(1024)
|
||||||
print("Host is {host}".format(host=host))
|
print("Host is {host}".format(host=host))
|
||||||
if host:
|
if host:
|
||||||
if host=='bwg'.encode('ascii'):
|
latest_speed_dic = db.get_latest_speed()
|
||||||
self.request.sendall("50%\n".encode('ascii'))
|
for server in latest_speed_dic:
|
||||||
print('send to bwg')
|
if host == server.encode("ascii"):
|
||||||
if host=='hosteons'.encode('ascii'):
|
speed = int(server["speed"])
|
||||||
self.request.sendall("80%\n".encode('ascii'))
|
self.request.sendall(
|
||||||
|
"{weight}%\n".format(weight=speed).encode("ascii")
|
||||||
|
)
|
||||||
|
print("send to bwg with wight {weight}".format(weight=speed))
|
||||||
|
break
|
||||||
self.request.close()
|
self.request.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue