Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -81,7 +81,7 @@ def export_results(results, search_condition):
|
|
| 81 |
if not results:
|
| 82 |
return None, "エラー: エクスポートするデータがありません。"
|
| 83 |
|
| 84 |
-
filename = f"search_results_{datetime.now(JST).strftime('%Y
|
| 85 |
file_path = os.path.join("/tmp", filename)
|
| 86 |
|
| 87 |
execution_date = datetime.now(JST).strftime("%Y/%m/%d %H:%M:%S")
|
|
@@ -121,9 +121,11 @@ with gr.Blocks() as demo:
|
|
| 121 |
|
| 122 |
# エクスポート機能
|
| 123 |
export_button = gr.Button("TXTをエクスポートする")
|
| 124 |
-
export_output = gr.File(
|
| 125 |
export_status = gr.Textbox(label="エクスポートメッセージ", interactive=False)
|
| 126 |
|
|
|
|
|
|
|
| 127 |
search_button.click(
|
| 128 |
search_logs,
|
| 129 |
inputs=[file_input, search_word, year, month, day],
|
|
@@ -133,7 +135,14 @@ with gr.Blocks() as demo:
|
|
| 133 |
export_button.click(
|
| 134 |
export_results,
|
| 135 |
inputs=[result_table, search_condition_state],
|
| 136 |
-
outputs=[export_output, export_status]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
)
|
| 138 |
|
| 139 |
gr.Markdown(f"[📖 ヘルプページ]({SUPPORT_URL})")
|
|
|
|
| 81 |
if not results:
|
| 82 |
return None, "エラー: エクスポートするデータがありません。"
|
| 83 |
|
| 84 |
+
filename = f"search_results_{datetime.now(JST).strftime('%Y%m%d_%H%M%S')}.txt"
|
| 85 |
file_path = os.path.join("/tmp", filename)
|
| 86 |
|
| 87 |
execution_date = datetime.now(JST).strftime("%Y/%m/%d %H:%M:%S")
|
|
|
|
| 121 |
|
| 122 |
# エクスポート機能
|
| 123 |
export_button = gr.Button("TXTをエクスポートする")
|
| 124 |
+
export_output = gr.File(visible=False) # ファイル出力は非表示にする
|
| 125 |
export_status = gr.Textbox(label="エクスポートメッセージ", interactive=False)
|
| 126 |
|
| 127 |
+
download_button = gr.Button("結果をダウンロード", visible=False) # 常に "結果をダウンロード" に固定
|
| 128 |
+
|
| 129 |
search_button.click(
|
| 130 |
search_logs,
|
| 131 |
inputs=[file_input, search_word, year, month, day],
|
|
|
|
| 135 |
export_button.click(
|
| 136 |
export_results,
|
| 137 |
inputs=[result_table, search_condition_state],
|
| 138 |
+
outputs=[export_output, export_status, download_button]
|
| 139 |
+
)
|
| 140 |
+
|
| 141 |
+
# ダウンロードボタンをクリックでファイルを取得
|
| 142 |
+
download_button.click(
|
| 143 |
+
lambda file_path: file_path,
|
| 144 |
+
inputs=[export_output],
|
| 145 |
+
outputs=[export_output]
|
| 146 |
)
|
| 147 |
|
| 148 |
gr.Markdown(f"[📖 ヘルプページ]({SUPPORT_URL})")
|