morpheme.py 文件源码

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

项目:Sentences-analysis 作者: sungminoh 项目源码 文件源码
def posts_by_page():
    if request.method == 'GET':
        topic = ast.literal_eval(request.args.get('topic'))
        sources_ids = ast.literal_eval(request.args.get('sources'))
        format_string = formatstring(sources_ids)
        page = ast.literal_eval(request.args.get('page'))
        fromDate = format_fromDate(ast.literal_eval(request.args.get('fromDate')))
        toDate = format_toDate(ast.literal_eval(request.args.get('toDate')))

        app.logger.info('GET posts_by_page: topic(%s), sources_ids(%s), page(%s), from(%s), to(%s)'
                        % ('%s', format_string, '%s', '%s', '%s')
                        % tuple([topic] + sources_ids + [page, fromDate, toDate]))

        db = g.db
        cur = db.cursor()

        from_post_rnum = (page-1)*config['perpage']
        get_post_between(cur, topic, sources_ids, from_post_rnum, config['perpage'], fromDate, toDate)
        posts = [dict(id=int(row[0]), title=row[1], url=row[2], timestamp=row[3]) for row in cur.fetchall()]

        post_ruleset_count_dic = get_post_ruleset_count_dic(cur, topic, sources_ids, from_post_rnum, config['perpage'], fromDate, toDate)

        return jsonify(posts                    = posts,
                       post_ruleset_count_dic   = post_ruleset_count_dic)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号