Ejemplo n.º 1
0
 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())
Ejemplo n.º 2
0
 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())
Ejemplo n.º 3
0
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()
Ejemplo n.º 4
0
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')
Ejemplo n.º 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))
Ejemplo n.º 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())
Ejemplo n.º 7
0
def application(request):
    r = methods.dispatch(request.data.decode())
    return Response(str(r), r.http_status, mimetype='application/json')
Ejemplo n.º 8
0
def index():
    req = request.get_data().decode()
    response = methods.dispatch(req)
    return Response(str(response), response.http_status,
                    mimetype='application/json')
Ejemplo n.º 9
0
async def index(request):
    req = await request.text()
    response = methods.dispatch(req)
    return web.json_response(response, status=response.http_status)
Ejemplo n.º 10
0
def handle_message(request):
    response = methods.dispatch(request)
    if not isinstance(response, NotificationResponse):
        send(response, json=True)
Ejemplo n.º 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")
Ejemplo n.º 12
0
def handle_message(request):
    return methods.dispatch(request)
Ejemplo n.º 13
0
def application(request):
    r = methods.dispatch(request.data.decode())
    return Response(str(r), r.http_status, mimetype='application/json')
Ejemplo n.º 14
0
def jsonrpc(request):
    response = methods.dispatch(request.body.decode())
    return JsonResponse(response, status=response.http_status)
Ejemplo n.º 15
0
def handle_message(request):
    response = methods.dispatch(request)
    if not isinstance(response, NotificationResponse):
        send(response, json=True)
Ejemplo n.º 16
0
 def post(self):
     req = request.get_data().decode()
     response = methods.dispatch(req)
     return Response(str(response),
                     response.http_status,
                     mimetype='application/json')
Ejemplo n.º 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))
Ejemplo n.º 18
0
def jsonrpc(request):
    response = methods.dispatch(request.body.decode())
    return JsonResponse(response, status=response.http_status)
Ejemplo n.º 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')
Ejemplo n.º 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))
Ejemplo n.º 21
0
def handle_message(request):
    response = methods.dispatch(request)
    if not response.is_notification:
        send(response, json=True)