api_sitemap.py 712 B

1234567891011121314151617181920212223242526
  1. from .tool.func import *
  2. def api_sitemap_2(conn):
  3. curs = conn.cursor()
  4. if admin_check() == 1:
  5. data = '' + \
  6. '<?xml version="1.0" encoding="UTF-8"?>\n' + \
  7. '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n' + \
  8. ''
  9. curs.execute(db_change("select title from data"))
  10. for i in curs.fetchall():
  11. data += '<url><loc>' + flask.request.host_url + 'w/' + url_pas(i[0]) + '</loc></url>\n'
  12. data += '' + \
  13. '</urlset>' + \
  14. ''
  15. f = open("sitemap.xml", 'w')
  16. f.write(data)
  17. f.close()
  18. return flask.Response(data, mimetype = 'text/xml')
  19. else:
  20. return re_error('/ban')