main_view_file.py 562 B

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