考虑以下最简单的示例:
from flask_restplus import Api, Resource, fields
from .models import User
ns = api.namespace('users', description='User related operations')
user = api.model('User', {
'id': fields.Integer(readOnly=True, description='The user identifier'),
'name': fields.String(required=True, description='The users name'),
'password': fields.String(required=True, description='The users password')
})
@ns.route('/')
class UserList(Resource):
@ns.doc('list_users')
@ns.marshal_list_with(user)
def get(self):
data = User.query.all()
print "Print the response here!"
return data
我正在排除故障,我希望能够打印/记录 Flask-RestPlus 返回的 JSON 响应,我该怎么做?