manage.py 文件源码

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

项目:zsky 作者: wenguonideshou 项目源码 文件源码
def sitemap():    
    conn,curr = sphinx_conn()
    querysql='SELECT info_hash,create_time FROM film order by create_time desc limit 100'
    curr.execute(querysql)
    rows=curr.fetchall()
    sphinx_close(curr,conn)
    sitemaplist=[]
    for row in rows:
        info_hash = row['info_hash']
        mtime = datetime.datetime.fromtimestamp(int(row['create_time'])).strftime('%Y-%m-%d')
        url = domain+'hash/{}.html'.format(info_hash)
        url_xml = '<url><loc>{}</loc><lastmod>{}</lastmod><changefreq>daily</changefreq><priority>0.8</priority></url>'.format(url, mtime)
        sitemaplist.append(url_xml)
    xml_content = '<?xml version="1.0" encoding="UTF-8"?><urlset>{}</urlset>'.format("".join(x for x in sitemaplist))
    with open('static/sitemap.xml', 'wb') as f:
        f.write(xml_content)
        f.close()
    return send_from_directory(app.static_folder, request.path[1:])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号