tpl_filter.py 文件源码

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

项目:flask-reactjs 作者: lassegit 项目源码 文件源码
def get_assets(asset_type):
    path = os.path.join(current_app.root_path, current_app.config['TEMPLATE_FOLDER'], 'assets.json')
    assets = json.load(open(path, 'r'))
    output = ''

    if asset_type == 'css':
        output = '<link rel="stylesheet" href="{0}">'.format(assets['style']['css'])

    elif asset_type == 'js':
        manifest = assets['manifest']['js']
        manifest = manifest[1:]

        manifest_file = open(os.path.join(current_app.root_path, current_app.config['STATIC_FOLDER'], manifest), 'r')
        output += '<script>' + manifest_file.read() + '</script>'
        manifest_file.close()

        output += '<script src="{0}"></script>'.format(assets['vendor']['js'])
        output += '<script src="{0}"></script>'.format(assets['app']['js'])

    return jinja2.Markup(output)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号