逻辑的话还是蛮简单的,多查看一个文档就可以了。代码如下page = int(request.args.get('page')) if request.args.get('page') else 1
pagesize = 20
prev_page = page - 1 if page - 1 else 1
next_page = page + 1
# 关键字查询
keywords = request.args.get('keywords')
start_date = request.args.get('start_date')
end_date = request.args.get('end_date')
params_query = {}
query = Itunes.query
if keywords:
query = query.filter(Itunes.title.startswith(keywords))
params_query['keywords'] = keywords
if start_date and end_date:
start = '%s 00:00:00' % start_date
end = '%s 23:59:59' % end_date
start = int(time.mktime(time.strptime(start,'%Y-%m-%d %H:%M:%S')))
end = int(time.mktime(time.strptime(end,'%Y-%m-%d %H:%M:%S')))
query = query.filter(Itunes.create_time > start)
query = query.filter(Itunes.create_time