def delete(): deletion_id = int(request.form['blog_id']) Blog.delete().where(Blog.id == deletion_id).execute() successfully_deleted = Blog.get_or_none(Blog.id == deletion_id) result = jsonify({'status': successfully_deleted}) return result
def edit(): data = request.form target_blog = Blog.get_or_none(Blog.id == data['blog_id']) target_blog.title = data['blog_title'] target_blog.desc = data['blog_desc'] if target_blog.save(): successfully_edited = True result = jsonify({ 'status': successfully_edited, 'data': target_blog.as_dict() }) return result
def show(id): blog = Blog.get_or_none(Blog.title == id) blog_found = blog != None result = jsonify({'status': blog_found, 'data': blog.as_dict()}) return result