【发布时间】:2019-10-24 06:43:37
【问题描述】:
我写了两个api,一个是创建设备(POST),另一个是列出所有设备(GET)。
in app.py
---------
# Get the List of the devices
api.add_resource(DeviceDetail, "/v1/t/device/")
# Create new Devices
api.add_resource(DeviceDetail, "/v1/t/device/create")
in controller/device.py
class DeviceDetail(Resource):
def get():
#some code to list out all the device and return the response
def post():
#some code to insert the record to db and return the response
AssertionError: View function mapping is overwriting an existing endpoint function: devicedetail.
如果我将端点参数传递给 add_resource() 那么我没有收到任何错误。
# Get the List of the devices
api.add_resource(DeviceDetail, "/v1/t/device/",endpoint='get_the_list_of_deives')
# Create new Devices
api.add_resource(DeviceDetail, "/v1/t/device/create",endpoint='create_the_deivce')
所以我很困惑,它在这里做了什么。
【问题讨论】:
标签: python python-3.x flask flask-restful