python调用接口404_【已解决】Flask-Restful中对于接口无法实现不传递参数时执行post...

已有Flask-restful的api定义:class TaskAPI(Resource):

decorators = [login_required]

def get(self, userId, taskId):

def post(self, userId, taskId):

gLog.debug("self.rootArgs=%s", self.rootArgs)

api.add_resource(UserLocationAPI,   API_URL_PREFIX + ‘/users//tasks/’,     endpoint = ‘userTask’)

但是对于:

想要创建新任务时,taskId为空

以POST方式去访问:

/users/user-bb22f24e-3c27-4e7b-867a-b855e139b295/tasks

/users/user-bb22f24e-3c27-4e7b-867a-b855e139b295/tasks/

都无法执行到上述接口的post中

出现:

404 Not Found

Not Found

The requested URL was not found on the server.  If you entered the URL manually please check your spelling and try again.

flask-restful post 404 Not Found

->

去给add_resource,添加多个url:api.add_resource(TaskAPI,

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值