main_file.py 590 B

12345678910111213141516
  1. from .tool.func import *
  2. from . import main_error_404
  3. def main_file_2(conn, data):
  4. curs = conn.cursor()
  5. print(data)
  6. if re.search('\.txt$', data) or data == 'sitemap.xml':
  7. if data == 'robots.txt' and not os.path.exists('robots.txt'):
  8. return flask.Response('User-agent: *\nDisallow: /\nAllow: /$\nAllow: /w/', mimetype='text/plain')
  9. elif os.path.exists(data):
  10. return flask.send_from_directory('./', data)
  11. else:
  12. return main_error_404.main_error_404_2(conn)
  13. else:
  14. return main_error_404.main_error_404_2(conn)