main_file.py 593 B

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