예제 #1
0
def get_comments(item_id):
    """Return story with its comments"""
    try:
        resp = items.get_comments(item_id)
    except exceptions.NotFound:
        abort(404)

    return app.response_class(resp, mimetype='application/json')
예제 #2
0
def get_stories(page=None):
    """Return a page of HN stories"""
    if request.url_rule.rule in ('/ask', '/ask/'):
        page = 'ask'
    elif request.url_rule.rule in ('/stories/', '/stories'):
        page = ''

    try:
        resp = items.get_stories(page)
    except exceptions.NotFound:
        abort(404)

    return app.response_class(resp, mimetype='application/json')