Пилю JSON-RPC API юзая json-rpc 1.10.3 либу.
Есть сервер, в котором два метода, в которых я тяну поля с БД на MySQl и клиент.
Когда запускаю клиент, выдаёт Response 405 (Method Not Allowed)
может кто сталкивался с таким? или кто юзал эту либу и может что-то подсказать?
Спасибо
SERVER
from werkzeug.wrappers import Request, Response from werkzeug.serving import run_simple from jsonrpc import JSONRPCResponseManager, dispatcher HOST = 'localhost' PORT = 80 def __init__(self, conn): self.conn = conn @dispatcher.add_method def get_detailed_usage(self, serviceRef, fromDate, toDate, excludeCallsCoveredByBundleAllowance): sql_where = [] sql_vars = [] if serviceRef is not None: sql_where.append("pc.service_ref={}").format(serviceRef) sql_vars.append(serviceRef) if fromDate is not None: sql_where.append("rc.start_time={}").format(fromDate) sql_vars.append(fromDate) if toDate is not None: sql_where.append("rc.end_time={}").format(toDate) sql_vars.append(toDate) if excludeCallsCoveredByBundleAllowance is not None: sql_where.append("excludeCallsCoveredByBundleAllowance={}").format(excludeCallsCoveredByBundleAllowance) sql_vars.append(excludeCallsCoveredByBundleAllowance) sql_query = """ SELECT FROM JOIN ON """ if sql_where: sql_query += " WHERE" + " AND ".join(sql_where) cursor = self.conn.cursor() cursor.execute(sql_query, *sql_vars) result = cursor.fetchall() return dict(result) @dispatcher.add_method def get_summary_usage(self, serviceRef, fromDate, toDate, excludeCallsCoveredByBundleAllowance): sql_where = [] sql_vars = [] if serviceRef is not None: sql_where.append("pc.service_ref={}").format(serviceRef) sql_vars.append(serviceRef) if fromDate is not None: sql_where.append("rc.start_time={}").format(fromDate) sql_vars.append(fromDate) if toDate is not None: sql_where.append("rc.end_time={}").format(toDate) sql_vars.append(toDate) if excludeCallsCoveredByBundleAllowance is not None: sql_where.append("excludeCallsCoveredByBundleAllowance={}").format(excludeCallsCoveredByBundleAllowance) sql_vars.append(excludeCallsCoveredByBundleAllowance) sql_query = """ SELECT FROM JOIN ON """ if sql_where: sql_query += " WHERE" + " AND ".join(sql_where) cursor = self.conn.cursor() cursor.execute(sql_query, *sql_vars) result = cursor.fetchall() return dict(result) def application(request): response = JSONRPCResponseManager.handle(request.data, dispatcher) return Response(response.json, response.http_status, mimetype='application/json') if __name__ == '__main__': run_simple(HOST, PORT, application)
CLIENT
import requests import json def main(): url = 'http://localhost:80' # headers = {'content-type': 'application/json'} result = { "jsonrpc": "2.0", "method": "get_detailed_usage", "params": [{"serviceRef": "1234", "fromDate": "2017-01-01 00:00:00", "toDate": "2017-01-31 23:59:59"}], "id": 0, } response = requests.post(url, data=json.dumps(result)) print(response) if __name__ == "__main__": main()