web.py 文件源码

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

项目:musicbot 作者: AdrienPensart 项目源码 文件源码
def get_stats():
    '''Music library statistics'''
    page_format = request.args.get('format', 'html')
    collection = app.config['COLLECTION']
    stats = webfilter(partial(collection.stats, cursor_factory=RealDictCursor))
    def bytesToHuman(b):
        return humanfriendly.format_size(b)
    def secondsToHuman(s):
        import datetime
        return str(datetime.timedelta(seconds=s))
    if page_format == 'html':
        return render_template("stats.html", stats=stats, bytesToHuman=bytesToHuman, secondsToHuman=secondsToHuman)
    elif page_format == 'json':
        return dumps(stats)
    return ('Invalid format, available: json,html', 400)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号