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
I used flaskr as a base for my Flask project (as it looks like you did as well).
In the .py:
@app.route('/delete', methods=['POST'])
def delete_entry():
if not session.get('logged_in'):
abort(401)
g.db.execute('delete from entries where id = ?', [request.form['entry_id']])
g.db.commit()
flash('Entry deleted')
return redirect(url_for('show_entries'))
In the HTML:
I wanted a button, but you could easily use a link with the solution here.