main_file.py 1.0 KB

123456789101112131415161718192021222324
  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 == 'easter_egg.html':
  6. return easy_minify(flask.render_template(skin_check(),
  7. imp = ['easter_egg.html', wiki_set(), custom(), other2([0, 0])],
  8. data = open('./views/main_css/file/easter_egg.html', encoding='utf8').read(),
  9. menu = 0
  10. ))
  11. elif re.search(r'\.(txt|xml)$', data, flags = re.I):
  12. if data == 'robots.txt' and not os.path.exists('robots.txt'):
  13. return flask.Response('User-agent: *\nDisallow: /\nAllow: /$\nAllow: /w/', mimetype = 'text/plain')
  14. elif os.path.exists(data):
  15. if re.search(r'\.txt$', data, flags = re.I):
  16. return flask.send_from_directory('./', data, mimetype = 'text/plain')
  17. else:
  18. return flask.send_from_directory('./', data, mimetype = 'text/xml')
  19. else:
  20. return main_error_404.main_error_404_2(conn)
  21. else:
  22. return main_error_404.main_error_404_2(conn)