小编Ren*_*h R的帖子

如何在python Flask中使用Delete方法

如何在 python flask 中使用 Delete 方法。我的代码段有一些问题,它在加载 url http://localhost:8082/api/users/remove_group/5时显示 Method Not Allowed 。

@app.route('/api/users/remove_group/<int:groupId>',methods=['DELETE'])
def removeGroup(groupId):
try:
    print 'its working--Delete group'
    if userGroup.query.filter_by(group_id=groupId).first() is not None:
        userGroup.query.filter_by(group_id=groupId).delete()
        message='Group removed succesfully\n'
    else:
        print 'Group not found'
        message='Group not found\n'
except HTTPException as error:
    return error(os.version)
return message
Run Code Online (Sandbox Code Playgroud)

html python flask-sqlalchemy

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

flask-sqlalchemy ×1

html ×1

python ×1