From 62606857ddf0eed190d5f5f42d4adb6ca0d93fcd Mon Sep 17 00:00:00 2001 From: tdurieux Date: Thu, 19 Oct 2017 11:45:16 +0200 Subject: [PATCH] fix content-type --- server.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/server.py b/server.py index 6ffba6f..a8dbe1b 100644 --- a/server.py +++ b/server.py @@ -164,7 +164,7 @@ class Anonymous_Github: file_path = current_file.path cached_file_path = os.path.join(cache_path, file_path) if os.path.exists(cached_file_path): - return send_from_directory(os.path.dirname(cached_file_path), os.path.basename(cached_file_path)) + return send_from_directory(os.path.dirname(cached_file_path), os.path.basename(cached_file_path), mimetype=get_type_content(path, path, data, g_repo)) content = '' if is_website(path, repository_config, g_repo): if current_file.size > 1000000: @@ -250,12 +250,11 @@ class Anonymous_Github: cache_path = os.path.join(self.config_dir, id, "cache") if os.path.isfile(os.path.join(cache_path, path)): return send_from_directory(os.path.dirname(os.path.join(cache_path, path)), - os.path.basename(os.path.join(cache_path, path))),\ - {'Content-Type': get_type_content(path, path, data, g_repo)} + os.path.basename(os.path.join(cache_path, path)), mimetype=get_type_content(path, path, data, g_repo)), elif os.path.exists(os.path.join(cache_path, path, "index.html")): - return send_from_directory(os.path.join(cache_path, path), "index.html"), {'Content-Type': 'text/html; charset=utf-8'} + return send_from_directory(os.path.join(cache_path, path), "index.html", mimetype='text/html; charset=utf-8') elif os.path.exists(os.path.join(cache_path, path, "README.md")): - return send_from_directory(os.path.join(cache_path, path), "README.md"), {'Content-Type': 'text/html; charset=utf-8'} + return send_from_directory(os.path.join(cache_path, path), "README.md", mimetype='text/html; charset=utf-8') clean_path = path if len(clean_path) > 0 and clean_path[-1] == '/':