예제 #1
0
def main():
    handler = CalculadoraHandler()
    processor = Calculadora.Processor(handler)
    transport = TSocket.TServerSocket(host="127.0.0.1", port=9090)
    tfactory = TTransport.TBufferedTransportFactory()
    pfactory = TBinaryProtocol.TBinaryProtocolFactory()

    server = TServer.TSimpleServer(processor, transport, tfactory, pfactory)

    print("iniciando servidor...")
    server.serve()
    print("fin")
예제 #2
0
import sys
sys.path.append('gen-py')

from thrift.transport import TSocket
from thrift.server import TServer
from calculadora import Calculadora


class CalculadoraHandler:
    def suma(self, numero1, numero2):
        return numero1 + numero2

    def resta(self, numero1, numero2):
        return numero1 - numero2

    def multiplicacion(self, numero1, numero2):
        return numero1 * numero2

    def division(self, numero1, numero2):
        return numero1 / numero2 if (numero2 != 0) else 0


if __name__ == "__main__":
    socket = TSocket.TServerSocket(port=9000)
    procesador = Calculadora.Processor(CalculadoraHandler())
    server = TServer.TSimpleServer(procesador, socket)
    print("Iniciando servidor...")
    server.serve()
예제 #3
0
파일: servidor.py 프로젝트: thejosess/DSD
        result.exponente_x = f1.exponente_x
        result.exponente_y = f1.exponente_y
        result.exponente_z = f1.exponente_z
        return result

    def derivadaFunciones(self, f1):
        print("derivando funcion")
        result = funcion(0, 0, 0, 0, 0, 0)
        result.z = f1.y
        result.y = f1.x * 2
        result.x = 0

        result.exponente_x = f1.exponente_x
        result.exponente_y = f1.exponente_y
        result.exponente_z = f1.exponente_z
        return result


if __name__ == '__main__':
    handler = CalculadoraHandler()
    processor = Calculadora.Processor(handler)
    transport = TSocket.TServerSocket(host='127.0.0.1', port=9090)
    tfactory = TTransport.TBufferedTransportFactory()
    pfactory = TBinaryProtocol.TBinaryProtocolFactory()

    server = TServer.TSimpleServer(processor, transport, tfactory, pfactory)

    print('Iniciando servidor...')
    server.serve()
    print('done.')