start making server
This commit is contained in:
parent
d536d076b6
commit
7514694ba7
15
server.py
15
server.py
|
@ -2,15 +2,20 @@
|
|||
|
||||
from twisted.internet import protocol, reactor, endpoints
|
||||
|
||||
class Echo(protocol.Protocol):
|
||||
class Reply(protocol.Protocol):
|
||||
def dataReceived(self, data):
|
||||
self.transport.write(data)
|
||||
data = str(data).split(':')
|
||||
if len(data) > 3:
|
||||
output = "yes"
|
||||
else:
|
||||
output = 'ERROR:INVALID_INP'
|
||||
self.transport.write('LICKTHECOINS:{}\n'.format(output).encode('utf-8'))
|
||||
|
||||
class EchoFactory(protocol.Factory):
|
||||
class Factory(protocol.Factory):
|
||||
def buildProtocol(self, addr):
|
||||
return Echo()
|
||||
return Reply()
|
||||
|
||||
endpoints.serverFromString(reactor, "tcp:13327").listen(EchoFactory())
|
||||
endpoints.serverFromString(reactor, "tcp:13327").listen(Factory())
|
||||
reactor.run()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue