blueprint.py 文件源码

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

项目:redberry 作者: michaelcho 项目源码 文件源码
def build_sitemap():
    from redberry.models import RedPost, RedCategory
    from apesmit import Sitemap
    sm = Sitemap(changefreq='weekly')

    for post in RedPost.all_published():
        sm.add(url_for('redberry.show_post', slug=post.slug, _external=True), lastmod=post.updated_at.date())

    for category in RedCategory.query.all():
        sm.add(url_for('redberry.show_category', category_slug=category.slug, _external=True), lastmod=category.updated_at.date())

    with open(os.path.join(REDBERRY_ROOT, 'static', 'redberry', 'sitemap.xml'), 'w') as f:
        sm.write(f)

    flash("Sitemap created.", 'success')
    return redirect(url_for('redberry.home'))


##############
# ADMIN ROUTES
##############
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号