Beispiel #1
0
def classic_add_latest():
    temp = {
        'content': '人生不能象做菜,把所有料准备好再下锅',
        'fav_num': 11,
        'image': 'http://bl.7yue.pro/images/movie.8.png',
        'index': 8,
        'like_status': 0,
        'pubdate': '2018-06-22',
        'title': '李安《饮食男女》',
        'type': 100
    }

    with db.auto_commit():
        classic = Classic()
        classic.set_attrs(temp)
        db.session.add(classic)
    return "add success"
def get_detail(type, id):
    form = ClassicDetailForm(data={'type': type, 'id': id}).validate_for_api()
    res = Classic().detail(form.type.data, form.id.data)
    classic = ClassicCollection()
    data = classic.fill_single(res)
    return jsonify(data)
def get_previous(index):
    form = ClassicForm(data={'index': index}).validate_for_api()
    res = Classic().previous(form.index.data)
    classic = ClassicCollection()
    data = classic.fill_single(res)
    return jsonify(data)
def get_latest():
    res = Classic().latest
    classic = ClassicCollection()
    data = classic.fill_single(res)
    return jsonify(data)