Closed deptyped closed 4 years ago
Now all you have to do to change the serialization or deserialization is pass the function to the dispatcher, like this:
import ujson from flask import Flask, request, Response from jsonrpcserver import method, dispatch app = Flask(__name__) @method def ping(): return "pong" @app.route("/", methods=["POST"]) def index(): response = dispatch(request.get_data().decode(), serialize=ujson.dumps, deserialize=ujson.loads) return Response(str(response), response.http_status, mimetype="application/json") if __name__ == "__main__": app.run()
Thanks @deptyped 👌
Now all you have to do to change the serialization or deserialization is pass the function to the dispatcher, like this: