diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1da8522 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea diff --git a/be/.gitignore b/be/.gitignore index d47e2ec..3f9881e 100644 --- a/be/.gitignore +++ b/be/.gitignore @@ -1,6 +1,6 @@ .idea __pycache__ app/projects/* -.idea/ -../../.idea + + diff --git a/be/app/api/v1/files.py b/be/app/api/v1/files.py index b920387..0de7088 100644 --- a/be/app/api/v1/files.py +++ b/be/app/api/v1/files.py @@ -8,6 +8,8 @@ import os from ...entities.entities import ReturnInfo, FileInfo from ...libs.tools import read_json_file,read_txt_file,write_json +import threading +import time # api = RedPrint('files') @@ -100,7 +102,14 @@ def get_json(): as_attachment=True)) response.headers["Content-disposition"] = 'attachment; filename={}_result.json'.format(project_name) # print(PROJECT_PATH.format(project_name)+'/result.json') - os.remove(PROJECT_PATH.format(project_name)+'/result.json') + # os.remove(PROJECT_PATH.format(project_name)+'/result.json') + + def delete(): + time.sleep(3) + os.remove(PROJECT_PATH.format(project_name) + '/result.json') + print('result.json has been deleted') + thread = threading.Thread(target=delete) + thread.start() return response # 3. 直接使用send from directory 返回json文件