diff --git a/flask_app/general/format_change.py b/flask_app/general/format_change.py index a69da6b..14f99f0 100644 --- a/flask_app/general/format_change.py +++ b/flask_app/general/format_change.py @@ -66,7 +66,6 @@ def docx2pdf(local_path_in): downloaded_filepath,file_type = download_file(receive_download_url, local_filename) print(f"format_change d2p:have downloaded file to: {downloaded_filepath}") return downloaded_filepath - # def docx2pdf(file_path): # """ # 将本地的 .docx 或 .doc 文件转换为 .pdf 文件。 diff --git a/flask_app/main/start_up.py b/flask_app/main/start_up.py index a3206a8..d07d3a4 100644 --- a/flask_app/main/start_up.py +++ b/flask_app/main/start_up.py @@ -176,7 +176,7 @@ def get_procurement_reqs(): return jsonify({ 'message': 'procurement_reqs processed successfully', 'filename': "filename", - 'data': response + 'data': json.dumps(response, ensure_ascii=False) }) except Exception as e: logger.error('Exception occurred: ' + str(e)) # 使用全局 logger 记录 @@ -386,7 +386,7 @@ def process_and_stream(file_url, zb_type): procurement_reqs_response={ 'message': 'procurement_reqs', 'filename': os.path.basename(downloaded_filepath), - 'data': procurement_reqs + 'data': json.dumps(procurement_reqs, ensure_ascii=False) } yield f"data: {json.dumps(procurement_reqs_response, ensure_ascii=False)}\n\n" diff --git a/flask_app/testdir/截取文件格式.py b/flask_app/testdir/截取文件格式.py index 2f7221a..1671fb5 100644 --- a/flask_app/testdir/截取文件格式.py +++ b/flask_app/testdir/截取文件格式.py @@ -178,7 +178,6 @@ def process_input(input_path, output_folder, begin_pattern, begin_page, end_patt generated_files.append(result) else: print("提供的路径既不是文件夹也不是PDF/Word文件。") - return [f for f in generated_files if f] # 过滤空字符串 @@ -191,7 +190,6 @@ def truncate_pdf_main(input_path, output_folder, selection): begin_page = 10 begin_pattern = re.compile( r'^第[一二三四五六七八九十百千]+(?:章|部分).*?(?:响应|投标).*?格式.*', - re.MULTILINE ) end_pattern = re.compile( r'^第[一二三四五六七八九十百千]+(?:章|部分)\s*[\u4e00-\u9fff]+', @@ -211,9 +209,10 @@ def truncate_pdf_main(input_path, output_folder, selection): if __name__ == "__main__": # 定义输入和输出路径 - input_path = "C:\\Users\\Administrator\\Desktop\\货物标\\zbfiles\\包头市公安支队机动车查验监管系统招标文201907.pdf" + # input_path = "C:\\Users\\Administrator\\Desktop\\货物标\\zbfiles" + input_path="C:\\Users\\Administrator\\Desktop\\招标文件\\招标test文件夹" output_folder = "C:\\Users\\Administrator\\Desktop\\货物标\\zbfiles\\新建文件夹" selection = 1 # 1 - 投标文件格式 # 执行截取 generated_files = truncate_pdf_main(input_path, output_folder, selection) - print("生成的文件:", generated_files) + # print("生成的文件:", generated_files)