-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathws_app.py
88 lines (75 loc) · 7.84 KB
/
ws_app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import os
from SimpleWebSocketServer import SimpleWebSocketServer, WebSocket
clients = []
class SimpleChat(WebSocket):
yes_num = 0
no_num = 0
def handleMessage(self):
if "Blinded message" in self.data:
os.system('cls' if os.name == 'nt' else 'clear')
if "Decoded message" in self.data:
answer = int(self.data[-1])
if (answer == 1):
SimpleChat.yes_num += 1
else:
SimpleChat.no_num += 1
print(self.data)
print("")
if "Verification" in self.data:
print("")
print("")
print("")
print("")
print("------------------------------------------------------------------------` YES VOTES: " + str(SimpleChat.yes_num) + " NO VOTES: " + str(SimpleChat.no_num) + " ---------------------------------------------------------------------------")
print("")
print("")
print("")
print("")
for client in clients:
if client != self:
client.sendMessage(self.address[0] + u' - ' + self.data)
def handleConnected(self):
#print(self.address, 'connected')
for client in clients:
client.sendMessage(self.address[0] + u' - connected')
clients.append(self)
def handleClose(self):
clients.remove(self)
#print(self.address, 'closed')
for client in clients:
client.sendMessage(self.address[0] + u' - disconnected')
server = SimpleWebSocketServer('', 8000, SimpleChat)
os.system('cls' if os.name == 'nt' else 'clear')
welcomeString = "Public Polling Center Listener"
print( '{:-^204}'.format(""))
print("----- -----")
print("----- -----")
print("----- -----")
print("----- -----")
print("----- -----")
print("----- -----")
print("----- -----")
print("----- -----")
print("----- -----")
print("----- -----")
print("----- -----")
print("----- -----")
print("----- Public Polling Center Listener -----")
print("----- RSA Blind Signature -----")
print("----- Voting Software -----")
print("----- V1.0 -----")
print("----- -----")
print("----- -----")
print("----- -----")
print("----- -----")
print("----- -----")
print("----- -----")
print("----- -----")
print("----- -----")
print("----- -----")
print("----- -----")
print("----- -----")
print("----- -----")
print("----- -----")
print( '{:-^204}'.format(""))
server.serveforever()