示例#1
0
def index():
    articles = query_articles()
    return render_template('list.jinja2.html', 
                           page_type="listing",
                           articles=articles,
                           list_active="active",
                           **opts)
示例#2
0
def since(days_ago):
    articles = query_articles(days_ago=days_ago)
    return render_template('list.jinja2.html',
                           page_type="since",
                           days_ago=days_ago,
                           articles=articles,
                           list_active="active",
                           **opts)
示例#3
0
def articles_json():
    # fetch articles
    articles = query_articles()
    # convert into dictionaries
    records = [vars(article) for article in articles]
    # dump list of dictionaries as JSON
    resp = json.dumps(records)
    # make a JSON HTTP response
    resp = make_response(resp)
    resp.headers["Content-Type"] = "application/json"
    return resp