main_view_file.py 629 B

1234567891011121314
  1. from .tool.func import *
  2. from .main_error_404 import main_error_404
  3. def main_view_file(data = ''):
  4. with get_db_connect() as conn:
  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()