def __init__(self, host, port, static_path, fetch_handler, search_handler, search_proxy_handler): self.host = host self.port = port SearchServer.FETCH_HANDLER = fetch_handler SearchServer.STATIC_PATH = static_path fetch_processor = FetchCommunicationService.Processor(fetch_handler) fetch_pfactory = TJSONProtocol.TJSONProtocolFactory() SearchServer.FETCH_TSERVER = TServer.TServer(fetch_processor, None, None, None, fetch_pfactory, fetch_pfactory) search_processor = SearchService.Processor(search_handler) search_pfactory = TJSONProtocol.TJSONProtocolFactory() SearchServer.SEARCH_TSERVER = TServer.TServer(search_processor, None, None, None, search_pfactory, search_pfactory) search_proxy_processor = SearchProxyService.Processor( search_proxy_handler) search_proxy_pfactory = TJSONProtocol.TJSONProtocolFactory() SearchServer.SEARCH_PROXY_TSERVER = TServer.TServer( search_proxy_processor, None, None, None, search_proxy_pfactory, search_proxy_pfactory)
def __init__(self, host, port, static_path, fetch_handler, store_handler): self.host = host self.port = port AccessHTTPServer.STATIC_PATH = static_path AccessHTTPServer.FETCH_HANDLER = fetch_handler fetch_processor = FetchCommunicationService.Processor(fetch_handler) fetch_pfactory = TJSONProtocol.TJSONProtocolFactory() AccessHTTPServer.FETCH_TSERVER = TServer.TServer( fetch_processor, None, None, None, fetch_pfactory, fetch_pfactory) AccessHTTPServer.STORE_HANDLER = store_handler store_processor = StoreCommunicationService.Processor(store_handler) store_pfactory = TJSONProtocol.TJSONProtocolFactory() AccessHTTPServer.STORE_TSERVER = TServer.TServer( store_processor, None, None, None, store_pfactory, store_pfactory)
def web_sync_service(): processor = Web_Sync.Processor(handler) protocol = TJSONProtocol.TJSONProtocolFactory() server = TServer.TServer(processor, None, None, None, protocol, protocol) itrans = TTransport.TMemoryBuffer(request.data) otrans = TTransport.TMemoryBuffer() iprot = server.inputProtocolFactory.getProtocol(itrans) oprot = server.outputProtocolFactory.getProtocol(otrans) server.processor.process(iprot, oprot) return make_response(otrans.getvalue())
def __init__(self, host, port, fetch_handler): """ Args: - `host`: - `port`: - `fetch_handler`: """ self.host = host self.port = port QuicklimeServer.FETCH_HANDLER = fetch_handler processor = FetchCommunicationService.Processor(fetch_handler) pfactory = TJSONProtocol.TJSONProtocolFactory() QuicklimeServer.TSERVER = TServer.TServer(processor, None, None, None, pfactory, pfactory)
server.serve() print('done.') import sys sys.path.append('gen-py') from flask import Flask, request, make_response from thrift.protocol import TJSONProtocol from thrift.server import TServer from thrift.transport import TTransport from tutorial import CodechatSyc handler = CodechatHandler() processor = CodechatSyc.Processor(handler) protocol = TJSONProtocol.TJSONProtocolFactory() server = TServer.TServer(processor, None, None, None, protocol, protocol) app = Flask(__name__) @app.route('/', methods=['POST']) def service1(): itrans = TTransport.TMemoryBuffer(request.data) otrans = TTransport.TMemoryBuffer() iprot = server.inputProtocolFactory.getProtocol(itrans) oprot = server.outputProtocolFactory.getProtocol(otrans) server.processor.process(iprot, oprot) return make_response(otrans.getvalue()) @app.route('/skeleton/<int:unique_id>')
return _requires_authorization class HelloWorldHandler(object): def ping(self): print "ping ..." @requires_authorization('Basic Authenticate required') def echo(self, msg): return 'Hello %s: %s' % (g.user, msg) handler = HelloWorldHandler() processor = HelloWorld.Processor(handler) pfactory = TBinaryProtocol.TBinaryProtocolFactory() hello_server = TServer.TServer(processor, None, None, None, pfactory, pfactory) app = Flask(__name__) @app.route('/_thrift', methods=['POST']) def _thrift(): itrans = TTransport.TMemoryBuffer(request.data) otrans = TTransport.TMemoryBuffer() iprot = hello_server.inputProtocolFactory.getProtocol(itrans) oprot = hello_server.outputProtocolFactory.getProtocol(otrans) hello_server.processor.process(iprot, oprot) return make_response(otrans.getvalue()) if __name__ == '__main__':