browser.py 文件源码

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

项目:Alexandria 作者: indrora 项目源码 文件源码
def preview_file(name):
    # get information about the file
    basepath=app.config.get("storage", "location")

    # Now, we're going to join the two together and normalize path
    fullpath = safe_join(basepath, name)

    # TODO: This could be nicer. 
    if(not os.path.exists(fullpath)):
        abort(404)



    parent_dir='/'.join(name.split('/')[:-1])

    file_stat = os.stat(fullpath)
    file_record = {
        "path":name,
        "name":name.split('/')[-1],
        "size":sizeof_fmt(file_stat.st_size)
    }
    previews = get_previews(name)
    if(len(previews) > 0):
        file_record["previews"] = previews
    # Render the preview template.
    return render_template('browser/preview_panel.html',
        parent_dir=parent_dir,
        file=file_record
        )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号