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 | |
James E. King III | 3ec4031 | 2019-01-31 18:35:51 -0500 | [diff] [blame] | 8 | |
ra | 779b9ac | 2014-04-23 20:04:23 -0700 | [diff] [blame] | 9 | class HelloSvcHandler: |
James E. King III | 3ec4031 | 2019-01-31 18:35:51 -0500 | [diff] [blame] | 10 | def hello_func(self): |
| 11 | print("Hello Called") |
| 12 | return "hello from Python" |
| 13 | |
ra | 779b9ac | 2014-04-23 20:04:23 -0700 | [diff] [blame] | 14 | |
| 15 | processor = HelloSvc.Processor(HelloSvcHandler()) |
| 16 | protoFactory = TJSONProtocol.TJSONProtocolFactory() |
| 17 | port = 9090 |
| 18 | server = THttpServer.THttpServer(processor, ("localhost", port), protoFactory) |
| 19 | print "Python server running on port " + str(port) |
| 20 | server.serve() |