Deleting rows from database with python flask?

前端 未结 4 893
一整个雨季
一整个雨季 2021-01-01 05:58

I am using a flask framework, and can\'t seem to delete rows from the database. The code below gives a 405 error: \"The method is not allowed for the requested URL.\" Any id

4条回答
  •  礼貌的吻别
    2021-01-01 06:39

    Clicking delete will issue a GET request, and your delete_entry method only responds to POST.

    You need to either 1. replace the link with a form & submit button or 2. have the link submit a hidden form with JavaScript.

    Here's how to do 1:

    '); form.submit(); }); }); ... Delete

    One thing you should not do is make your delete_entry method respond to GET. GETs are meant to be idempotent (are safe to run repeatedly and don't perform destructive actions). Here's a question with some more details.

提交回复
热议问题