()
return {'status': 'ok',
            'htmls': res }
return a dict of {pagenum: 'html'}
return a dict of {pagenum: 'html'}
return a dict of { pagenum : html }
def html():
    """ return a dict of {pagenum: 'html'} """
    try:
        pid = long(request.values.get('pid'))
        page_str = request.values.get('page')
        pages = map(int, page_str.split(','))
    except Exception:
        return {'status': 'error',
                'reason': 'invalid request'}
    db = get_mongo('paper')
    doc = db.find_one({'_id': pid}, {'page': 1, 'html': 1})

    if max(pages) > doc['page'] or min(pages) < 0:
        return {'status': 'error',
                'reason': 'invalid page index'}

    res = {}
    for p in pages:
        res[p] = doc['html'][p]
    return {'status': 'ok',
            'htmls': res }
def html ( ) : try : pid = long ( request . values . get ( 'pid' ) ) page_str = request . values . get ( 'page' ) pages = map ( int , page_str . split ( ',' ) ) except Exception : return { 'status' : 'error' , 'reason' : 'invalid request' } db = get_mongo ( 'paper' ) doc = db . find_one ( { '_id' : pid } , { 'page' : 1 , 'html' : 1 } ) if max ( pages ) > doc [ 'page' ] or min ( pages ) < 0 : return { 'status' : 'error' , 'reason' : 'invalid page index' } res = { } for p in pages : res [ p ] = doc [ 'html' ] [ p ] return { 'status' : 'ok' , 'htmls' : res }