def delete_comment(comment_id): cookies = request.cookies if 'token' not in cookies: return jsonify(), 401 with connect(DSN) as connection: with connection.cursor(cursor_factory=RealDictCursor) as cursor: cursor.execute(Users.get_user_id(), cookies) user_id = cursor.fetchone()['user_id'] cursor.execute(Comments.get_author_id(), {'id': comment_id}) author_id = cursor.fetchone()['author_id'] if user_id != author_id: return jsonify(), 401 with connect(DSN) as connection: with connection.cursor(cursor_factory=RealDictCursor) as cursor: cursor.execute(Comments.delete(), {'id': comment_id}) return jsonify(), 205