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:])
评论列表
文章目录