コード例 #1
0
def publish_article():
    if request.method == 'POST':
        title = request.form.get('title')
        type_id = request.form.get('type')
        content = request.form.get('content')
        article = Article()
        article.title = title
        article.type_id = type_id
        article.content = content
        article.user_id = g.user.id
        db.session.add(article)
        db.session.commit()
        return redirect(url_for('user.index'))
コード例 #2
0
ファイル: view.py プロジェクト: wsq1996/personalblog-
def publish_article():
    if request.method == 'POST':
        title = request.form.get('title')
        type_id = request.form.get('type')
        content = request.form.get('content')
        article = Article()
        article.title = title
        article.type_id = type_id
        article.content = content.encode('utf-8')
        article.userId = g.user.id
        db.session.add(article)
        db.session.commit()
        return redirect(url_for('user.index'))
    return render_template('user/user_center.html')
コード例 #3
0
ファイル: views.py プロジェクト: bang77/flask05
def publish_article():
    if request.method == 'POST':
        title = request.form.get('title')
        type_id = request.form.get('type')
        content = request.form.get('content')
        # print(title)
        # print(type_id)
        # print(content)
        # print(g.user.id)
        # 添加文章
        article = Article()
        article.title = title
        article.content = content
        article.type_id = type_id
        #
        article.user_id = g.user.id
        #
        db.session.add(article)
        db.session.commit()
        # return '发表成功!'
        return redirect(url_for('user.index'))