from flask_restful import Resource, reqparse, abort, fields, marshal_with import json class Send(Resource): def setup_request_parser(self): parser = reqparse.RequestParser() parser.add_argument( "client_id", type=str, help="A unique name to identify the client" ) parser.add_argument( "secret", type=str, help="A human friendly name to identify the client" ) parser.add_argument("topic", type=str, help="Publisher topic") parser.add_argument("content", type=str, help="The message") self.parser = parser def parse(self): return self.parser.parse_args() def put(self, client_id): args = clients_file.parse() client = clients_file.find(client_id) if not client: abort(404, message="No client with id: {}".format(client_id)) else: client = clients_file.update(args) return client, 201