7

How to use Delete method in python flask.My code segment has some issues and it shows Method Not Allowed while loading the url http://localhost:8082/api/users/remove_group/5.

@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
Renjith R
  • 109
  • 1
  • 1
  • 5

1 Answers1

0

HTML suports only GET/POST requests in forms, isn't it? Thus, you might try to get access to your removeGroup method with POST request that is not allowed in @app.route.

Please, see also: Should PUT and DELETE be used in forms?

pch
  • 533
  • 6
  • 11
  • 7
    Your answer is inrelevant to the question. How can your server handle DELETE requests. It is flask, serverside code. The request doesn't have to be comming from a form. – gkont May 17 '20 at 13:09