Advertisement
lessientelrunya

Delete Info DB

Apr 19th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. @app.route('/posts/<int:post_id>/delete', methods=['POST'])
  2. @login_required
  3. def delete_post(post_id):
  4.     cursor = g.db.execute("SELECT id,user_id from post WHERE id=:post_id;",{'post_id':post_id})
  5.     post = cursor.fetchone()
  6.    
  7.     if post is not None:
  8.         if session['user_id'] == post[1]:
  9.             g.db.execute("DELETE FROM post WHERE id={};".format(post_id))
  10.             g.db.commit()
  11.             return redirect('/', 302)
  12.  
  13.     return redirect('/', 404)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement