Просмотр исходного кода

fix: 1. 修复写markdown乱码 2. 更新readme

houlinfeng 1 год назад
Родитель
Сommit
19ae33d83c
2 измененных файлов с 3 добавлено и 3 удалено
  1. 1 1
      projects/web_demo/README.md
  2. 2 2
      projects/web_demo/web_demo/api/analysis/pdf_ext.py

+ 1 - 1
projects/web_demo/README.md

@@ -36,7 +36,7 @@ pip3 install -r requirements.txt  -i https://pypi.tuna.tsinghua.edu.cn/simple
 # 进入程序目录
 cd projects/web_demo/web_demo
 # 启动服务
-python3 app.py
+python3 app.py 或者 python app.py
 # 在浏览器访问启动的地址即可访问界面
 ```
 

+ 2 - 2
projects/web_demo/web_demo/api/analysis/pdf_ext.py

@@ -97,7 +97,7 @@ def analysis_pdf_task(pdf_dir, image_dir, pdf_path, is_ocr, analysis_pdf_id):
             full_md_content += item["md_content"] + "\n"
 
         full_md_name = "full.md"
-        with open(f"{pdf_dir}/{full_md_name}", "w") as file:
+        with open(f"{pdf_dir}/{full_md_name}", "w", encoding="utf-8") as file:
             file.write(full_md_content)
         with app.app_context():
             full_md_link = url_for('analysis.mdview', filename=full_md_name, as_attachment=False)
@@ -108,7 +108,7 @@ def analysis_pdf_task(pdf_dir, image_dir, pdf_path, is_ocr, analysis_pdf_id):
             for n, md in enumerate(json.loads(md_content)):
                 md_content = md["md_content"]
                 md_name = f"{md.get('page_no', n)}.md"
-                with open(f"{pdf_dir}/{md_name}", "w") as file:
+                with open(f"{pdf_dir}/{md_name}", "w", encoding="utf-8") as file:
                     file.write(md_content)
                 md_url = url_for('analysis.mdview', filename=md_name, as_attachment=False)
                 md_link_list.append(f"{md_url}&pdf={pdf_name}")