Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,6 @@ from google.genai import types
|
|
| 4 |
import os
|
| 5 |
from dotenv import load_dotenv
|
| 6 |
import tempfile
|
| 7 |
-
from weasyprint import HTML
|
| 8 |
#pip3 install pdfkit' と 'brew install wkhtmltopdf'を実行してください
|
| 9 |
|
| 10 |
# Load environment variables
|
|
@@ -550,12 +549,6 @@ def change_input(prompt):
|
|
| 550 |
return gr.update(visible=False)
|
| 551 |
|
| 552 |
|
| 553 |
-
def convert_html_file_to_pdf(html_file_path, output_pdf_path):
|
| 554 |
-
"""HTMLファイルをPDFに変換する関数"""
|
| 555 |
-
HTML(filename=html_file_path).write_pdf(output_pdf_path)
|
| 556 |
-
return output_pdf_path
|
| 557 |
-
|
| 558 |
-
|
| 559 |
# --- Python function for the Gradio app ---
|
| 560 |
def generate_response(prompt):
|
| 561 |
"""
|
|
@@ -581,10 +574,7 @@ def generate_response(prompt):
|
|
| 581 |
|
| 582 |
# ファイルパスを取得
|
| 583 |
file_path = tmp_file.name
|
| 584 |
-
|
| 585 |
-
|
| 586 |
-
out_pdf = convert_html_file_to_pdf(file_path, 'output_weasyprint.pdf')
|
| 587 |
-
return final_html,out_pdf
|
| 588 |
except Exception as e:
|
| 589 |
return f"An error occurred: {e}"
|
| 590 |
|
|
|
|
| 4 |
import os
|
| 5 |
from dotenv import load_dotenv
|
| 6 |
import tempfile
|
|
|
|
| 7 |
#pip3 install pdfkit' と 'brew install wkhtmltopdf'を実行してください
|
| 8 |
|
| 9 |
# Load environment variables
|
|
|
|
| 549 |
return gr.update(visible=False)
|
| 550 |
|
| 551 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 552 |
# --- Python function for the Gradio app ---
|
| 553 |
def generate_response(prompt):
|
| 554 |
"""
|
|
|
|
| 574 |
|
| 575 |
# ファイルパスを取得
|
| 576 |
file_path = tmp_file.name
|
| 577 |
+
return final_html,file_path
|
|
|
|
|
|
|
|
|
|
| 578 |
except Exception as e:
|
| 579 |
return f"An error occurred: {e}"
|
| 580 |
|