flask的flask_restful添加二级路由
from flask import Flask
from flask_restful import Api, Resource
app = Flask(__name__)
api = Api(app)
class ParentResource(Resource):
def get(self):
return {'message': 'This is the parent resource'}
class ChildResource(Resource):
def get(self):
return {'message': 'This is the child resource'}
api.add_resource(ParentResource, '/api/Parent')
api.add_resource(ParentResource.ChildResource, '/api/Parent/Child')
if __name__ == '__main__':
app.run(debug=True)