示例#1
0
文件: post.py 项目: Ncare/blog_flask
def update_post(id):
    post = PostService.get_one(id)

    print(post)
    form = PostForm(title=post.get('title'), content=post.get('content'))
    if request.method == 'GET':
        return render_template('admin/update.html', form=form, post = post)

    title = request.form['title']
    content = request.form['content']


    dic = {'title':title, 'content':content}
    try:
        post= PostService.update_post(id, dic)
        print("success")
        flash('update success')
    except:
        flash('update failed')

    return redirect(url_for('admin.show_posts'))
示例#2
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)