这个版本主要添加了类视图支持(class-based views):
# ...
# use the "route" decorator to decorate the view class
@app.route('/')
class Hello(MethodView):
# use HTTP method name as class method name
def get(self):
return {'message': 'Hello!'}
@app.route('/pets/<int:pet_id>')
class Pet(MethodView):
@output(PetOutSchema)
def get(self, pet_id):
# ...
@input(PetInSchema)
@output(PetOutSchema)
def put(self, pet_id, data):
# ...