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