__init__.py 文件源码

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

项目:JmilkFan-s-Blog 作者: JmilkFan 项目源码 文件源码
def new_post():
    """View function for new_port."""

    form = PostForm()

    # Ensure the user logged in.
    # Flask-Login.current_user can be access current user.
    if not current_user:
        return redirect(url_for('main.login'))

    # Will be execute when click the submit in the create a new post page.
    if form.validate_on_submit():
        new_post = Post()
        new_post.title = form.title.data
        new_post.text = form.text.data
        new_post.publish_date = datetime.now()
        new_post.user = current_user

        db.session.add(new_post)
        db.session.commit()
        return redirect(url_for('blog.home'))

    return render_template('new_post.html',
                           form=form)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号