Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -82,11 +82,21 @@ def generate_download_link(results, search_condition):
|
|
| 82 |
if not results:
|
| 83 |
return "エラー: エクスポートするデータがありません。"
|
| 84 |
|
| 85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
|
| 87 |
file_content = (
|
| 88 |
"プログラム名: LINEログマネージャー\n"
|
| 89 |
-
f"検索実行日: {
|
| 90 |
f"{search_condition}\n"
|
| 91 |
f"ヒット件数: {len(results.splitlines())} 件\n"
|
| 92 |
+ "-" * 40 + "\n"
|
|
@@ -94,7 +104,7 @@ def generate_download_link(results, search_condition):
|
|
| 94 |
)
|
| 95 |
|
| 96 |
encoded_file = base64.b64encode(file_content.encode()).decode()
|
| 97 |
-
href = f'<a href="data:text/plain;base64,{encoded_file}" download="
|
| 98 |
return href
|
| 99 |
|
| 100 |
# Gradio UI
|
|
|
|
| 82 |
if not results:
|
| 83 |
return "エラー: エクスポートするデータがありません。"
|
| 84 |
|
| 85 |
+
execution_time = datetime.now(JST).strftime("%y%m%d_%H%M%S")
|
| 86 |
+
|
| 87 |
+
# 検索条件をファイル名に適用
|
| 88 |
+
if "ワード" in search_condition:
|
| 89 |
+
condition_text = search_condition.replace("検索条件: ワード[", "").replace("]", "").replace(" ", "_")
|
| 90 |
+
elif "日付" in search_condition:
|
| 91 |
+
condition_text = search_condition.replace("検索条件: 日付[", "").replace("]", "").replace("/", "_")
|
| 92 |
+
else:
|
| 93 |
+
condition_text = "検索条件なし"
|
| 94 |
+
|
| 95 |
+
file_name = f"{execution_time}_LINE-Log-Manager-search-Export-{condition_text}.txt"
|
| 96 |
|
| 97 |
file_content = (
|
| 98 |
"プログラム名: LINEログマネージャー\n"
|
| 99 |
+
f"検索実行日: {execution_time}\n"
|
| 100 |
f"{search_condition}\n"
|
| 101 |
f"ヒット件数: {len(results.splitlines())} 件\n"
|
| 102 |
+ "-" * 40 + "\n"
|
|
|
|
| 104 |
)
|
| 105 |
|
| 106 |
encoded_file = base64.b64encode(file_content.encode()).decode()
|
| 107 |
+
href = f'<a href="data:text/plain;base64,{encoded_file}" download="{file_name}">結果をダウンロード</a>'
|
| 108 |
return href
|
| 109 |
|
| 110 |
# Gradio UI
|