コード例 #1
0
ファイル: http_server.py プロジェクト: bcb/jsonrpcserver
 def do_POST(self):
     # Process request
     request = self.rfile.read(int(self.headers['Content-Length'])).decode()
     response = methods.dispatch(request)
     # Return response
     self.send_response(response.http_status)
     self.send_header('Content-type', 'application/json')
     self.end_headers()
     self.wfile.write(str(response).encode())
コード例 #2
0
ファイル: http_server.py プロジェクト: spumer/jsonrpcserver
 def do_POST(self):
     # Process request
     request = self.rfile.read(int(self.headers['Content-Length'])).decode()
     response = methods.dispatch(request)
     # Return response
     self.send_response(response.http_status)
     self.send_header('Content-type', 'application/json')
     self.end_headers()
     self.wfile.write(str(response).encode())
コード例 #3
0
ファイル: rpcserver-tcp.py プロジェクト: ajmal017/stock_mon
def handle_request(reader, writer):
    while True:
        request = yield from reader.read(1024)
        message = request.decode()
        addr = writer.get_extra_info('peename')
        response = methods.dispatch(request)
        if not isinstance(response, NotificationResponse):
            print("received %r from %r" % (message, addr))
            writer.write(response)
            yield from writer.drain()
コード例 #4
0
ファイル: xrmbalance.py プロジェクト: lemonclik/xrouterdev
def index():
    req = request.get_data().decode()
    req = json.loads(req)
    req["jsonrpc"] = "2.0"
    req = json.dumps(req)
    print(req)
    response = methods.dispatch(req)
    return Response(str(response),
                    response.http_status,
                    mimetype='application/json')
コード例 #5
0
 def _on_message(self, data):
     try:
         timeout = 5
         msg = native_str(data.decode('utf-8'))
         logging.info("Received: %s", msg)
         response = methods.dispatch(msg)
         if not isinstance(response, NotificationResponse):
             #write response
             self.write(str(response).encode(encoding="utf-8") + self.EOF)
         self.io_loop.add_timeout(self.io_loop.time() + timeout, self._on_timeout)
     except Exception as ex:
         logging.error("Exception: %s", str(ex))
コード例 #6
0
 def do_POST(self):
     request = self.rfile.read(int(
         self.headers['Content-Length'])).decode()
     # check if domain+path is requesting the jsonrpc
     host = self.headers['Host']
     # if (SERVER_DOMAIN not in host) or (self.path != RPC_PATH):
     if (self.path != RPC_PATH):
         self.forbidden(request)
         return
     # check if param sign is valid
     if self.is_request_valid(request) == False:
         self.forbidden(request)
         return
     # Process request
     response = methods.dispatch(request)
     # Return response
     self.send_response(response.http_status)
     self.send_header('Content-type', 'application/json')
     self.end_headers()
     self.wfile.write(json.dumps(response).encode())
コード例 #7
0
def application(request):
    r = methods.dispatch(request.data.decode())
    return Response(str(r), r.http_status, mimetype='application/json')
コード例 #8
0
ファイル: flask_server.py プロジェクト: bcb/jsonrpcserver
def index():
    req = request.get_data().decode()
    response = methods.dispatch(req)
    return Response(str(response), response.http_status,
                    mimetype='application/json')
コード例 #9
0
async def index(request):
    req = await request.text()
    response = methods.dispatch(req)
    return web.json_response(response, status=response.http_status)
コード例 #10
0
def handle_message(request):
    response = methods.dispatch(request)
    if not isinstance(response, NotificationResponse):
        send(response, json=True)
コード例 #11
0
def index():
    req = request.get_data().decode()
    response = methods.dispatch(req, context={'feature_enabled': True})
    return Response(str(response),
                    response.http_status,
                    mimetype="application/json")
コード例 #12
0
ファイル: socketio_server.py プロジェクト: bcb/jsonrpcserver
def handle_message(request):
    return methods.dispatch(request)
コード例 #13
0
def application(request):
    r = methods.dispatch(request.data.decode())
    return Response(str(r), r.http_status, mimetype='application/json')
コード例 #14
0
ファイル: django_server.py プロジェクト: bcb/jsonrpcserver
def jsonrpc(request):
    response = methods.dispatch(request.body.decode())
    return JsonResponse(response, status=response.http_status)
コード例 #15
0
def handle_message(request):
    response = methods.dispatch(request)
    if not isinstance(response, NotificationResponse):
        send(response, json=True)
コード例 #16
0
 def post(self):
     req = request.get_data().decode()
     response = methods.dispatch(req)
     return Response(str(response),
                     response.http_status,
                     mimetype='application/json')
コード例 #17
0
import zmq
from jsonrpcserver import methods
from jsonrpcserver.response import NotificationResponse

socket = zmq.Context().socket(zmq.REP)


@methods.add
def ping():
    return 'pong'


if __name__ == '__main__':
    socket.bind('tcp://*:5000')
    while True:
        request = socket.recv().decode()
        response = methods.dispatch(request)
        socket.send_string(str(response))
コード例 #18
0
ファイル: django_server.py プロジェクト: spumer/jsonrpcserver
def jsonrpc(request):
    response = methods.dispatch(request.body.decode())
    return JsonResponse(response, status=response.http_status)
コード例 #19
0
def rpc_main():
    print('in rpc_main')
    req = request.get_data().decode()
    response = methods.dispatch(req)
    print(response)
    return Response(str(response), response.http_status, mimetype='application/json')
コード例 #20
0
def main(websocket, path):
    request = yield from websocket.recv()
    response = methods.dispatch(request, context=bleserver)
    if not response.is_notification:
        yield from websocket.send(str(response))
コード例 #21
0
def handle_message(request):
    response = methods.dispatch(request)
    if not response.is_notification:
        send(response, json=True)