ra | 779b9ac | 2014-04-23 20:04:23 -0700 | [diff] [blame] | 1 | import sys |
| 2 | sys.path.append('gen-py') |
| 3 | |
| 4 | from hello import HelloSvc |
| 5 | from thrift.protocol import TJSONProtocol |
| 6 | from thrift.server import THttpServer |
| 7 | |
| 8 | class HelloSvcHandler: |
| 9 | def hello_func(self): |
| 10 | print "Hello Called" |
| 11 | return "hello from Python" |
| 12 | |
| 13 | processor = HelloSvc.Processor(HelloSvcHandler()) |
| 14 | protoFactory = TJSONProtocol.TJSONProtocolFactory() |
| 15 | port = 9090 |
| 16 | server = THttpServer.THttpServer(processor, ("localhost", port), protoFactory) |
| 17 | print "Python server running on port " + str(port) |
| 18 | server.serve() |
| 19 | |