tech_blog.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:high-school-trainee 作者: linkedin 项目源码 文件源码
def modify_blog_posts(id):
    """ RESTful routes for fetching, updating, or deleting a specific blog post """

    post = BlogPost.query.get(id)
    if not post:
        return jsonify({"message": "No blog post found with id " + str(id)}), 404
    if request.method == 'GET':
        return post
    elif request.method == 'PUT':
        data = request.form
        post.content = data["blog_content"]
        db.session.add(post)
        db.session.commit()
        return jsonify({"message": "Success!"}), 200
    else:
        db.session.delete(post)
        db.session.commit()
        return jsonify({"message": "Success!"}), 200
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号