Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import sys
- import os
- my_dir = os.path.dirname(os.path.realpath(sys.argv[0]))
- sys.path.insert(0, my_dir + '/gen-py')
- from example import Example
- from thrift.transport import TTransport
- from thrift.transport import TSocket
- from thrift.protocol import TBinaryProtocol
- from thrift.server import TServer
- class ExampleHandler:
- def add(self, a, b):
- return a +b
- handler = ExampleHandler()
- processor = Example.Processor(handler)
- transport = TSocket.TServerSocket(12345)
- tfactory = TTransport.TBufferedTransportFactory()
- pfactory = TBinaryProtocol.TBinaryProtocolFactory()
- server = TServer.TThreadedServer(processor, transport, tfactory, pfactory)
- server.serve()
Add Comment
Please, Sign In to add comment