예제 #1
0
파일: post.py 프로젝트: Ncare/blog_flask
def delete():

    if request.method == 'POST':
        data = request.json
        print(data)

        try:
            PostService.delete_post(data['post_id'])
            CommentService.delete_comments(data['post_id'])
        except Exception as e:
            print(e)
            return json.dumps({'has_error':True, 'message':"删除错误"})

        return jsonify(success=True, message="删除成功" )
예제 #2
0
파일: post.py 프로젝트: Ncare/blog_flask
def showComments():

    if request.method == 'POST':
        data = request.json

        try:
            comments = CommentService.get_comments(post_id=data['id'])
            count = CommentService.get_comments_count(post_id=data['id'])
        except:
            return json.dumps({'has_error':True, 'message':"查询出错"})


        if not count:
            return jsonify(success=True, count=0, message="没有评论")
        else:
            return  jsonify(success=True, count=count, info=comments)
예제 #3
0
파일: post.py 프로젝트: Ncare/blog_flask
def post(id):
    post = PostService.get_one(id)
    comment = CommentService.get_comments(id)

    return render_template('admin/posts.html', post=post, comment=comment)