How can I avoid the DELETE method giving me a 405 error? Is there any way to delete rows from my database?
I've tried including the following in the web.config file in my root directory, but this doesn't work.
<system.webServer>
<modules>
<remove name="WebDAVModule" />
</modules>
<handlers>
<remove name="WebDAV" />
</handlers>
</system.webServer>
I've included code snippets below for reference.
HTML:
<form method = "post" class= "my-5 text-center">
<caption>Remove Staff</caption>
<select name="staff" style="width: 300px">
<option></option>
{% for p in people %}
<option name="staff">{{ p.name }}</option>
{% endfor %}
</select>
<input type= "submit"/>
</form>
python:
@app.route("/deletestaff")
def deletestaff():
if request.method == "POST":
name = request.form.get("name")
db.execute("DELETE * FROM staff WHERE id=1")
people = db.execute("SELECT name, id FROM staff")
return render_template("deletestaff.html", people=people)
else:
people = db.execute("SELECT name, id FROM staff")
return render_template("deletestaff.html", people=people)