Esempio n. 1
0
def addArticle():
    form = request.form
    # 计算字数  就是计算字符串的长度
    numbers = len(form['content'])
    if request.method == 'POST':
        with db.auto_commit():
            article = Article()
            article.set_attrs(form)
            article.numbers = numbers
            db.session.add(article)
        return jsonify({'code': 200, 'message': '写入文章成功'})
Esempio n. 2
0
def addArticle():
    form = request.form
    # 计算字数  就是计算字符串的长度
    numbers = len(form['content'])
    if request.method == 'POST':
        with db.auto_commit():
            field = 0
            if len(form['project_name']) > 0:
                field = 1
            # 获取当前年份
            year = datetime.now().year
            article = Article()
            article.set_attrs(form)
            article.numbers = numbers
            article.year = year
            article.field = field
            db.session.add(article)
        return jsonify({'code': 200, 'message': '写入文章成功'})