Guest User

Untitled

a guest
May 25th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. #!/usr/bin/python
  2.  
  3. import sys
  4. import os
  5.  
  6. my_dir = os.path.dirname(os.path.realpath(sys.argv[0]))
  7.  
  8. sys.path.insert(0, my_dir + '/gen-py')
  9.  
  10. from example import Example
  11. from thrift.transport import TTransport
  12. from thrift.transport import TSocket
  13. from thrift.protocol import TBinaryProtocol
  14. from thrift.server import TServer
  15.  
  16. class ExampleHandler:
  17. def add(self, a, b):
  18. return a +b
  19.  
  20. handler = ExampleHandler()
  21. processor = Example.Processor(handler)
  22. transport = TSocket.TServerSocket(12345)
  23. tfactory = TTransport.TBufferedTransportFactory()
  24. pfactory = TBinaryProtocol.TBinaryProtocolFactory()
  25. server = TServer.TThreadedServer(processor, transport, tfactory, pfactory)
  26. server.serve()
Add Comment
Please, Sign In to add comment