Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import matplotlib.pyplot as plt
|
| 2 |
import io
|
| 3 |
import base64
|
|
@@ -8,6 +9,7 @@ import networkx as nx
|
|
| 8 |
from datetime import datetime, timedelta
|
| 9 |
import gradio as gr
|
| 10 |
import logging
|
|
|
|
| 11 |
|
| 12 |
# ===== εεθζ¨£εΌ =====
|
| 13 |
plt.rcParams['font.sans-serif'] = ['Microsoft JhengHei', 'Noto Sans TC', 'SimHei', 'Arial Unicode MS']
|
|
@@ -200,6 +202,9 @@ def run_analysis():
|
|
| 200 |
}
|
| 201 |
news_table = "<p>η‘ζ°θθ³ζ</p>"
|
| 202 |
|
|
|
|
|
|
|
|
|
|
| 203 |
# --- εθ葨 ---
|
| 204 |
engagement_table = f"""
|
| 205 |
<table class="min-w-full bg-white border border-gray-200">
|
|
@@ -219,7 +224,8 @@ def run_analysis():
|
|
| 219 |
with open(template_path, encoding='utf-8') as f:
|
| 220 |
html_template = f.read()
|
| 221 |
|
| 222 |
-
|
|
|
|
| 223 |
report_date=datetime.now().strftime('%Y-%m-%d %H:%M'),
|
| 224 |
engagement_table=engagement_table if engagement_table else "<p>ζͺζδΎδΊεζΈζ</p>",
|
| 225 |
news_summary=news_summary if news_summary else "<p>ζͺζδΎζ°θζθ¦</p>",
|
|
@@ -240,4 +246,4 @@ if __name__ == "__main__":
|
|
| 240 |
outputs=gr.HTML(),
|
| 241 |
title="2026 ι«ιεΈι·ιΈθθΌΏζ
εζ"
|
| 242 |
)
|
| 243 |
-
iface.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
| 1 |
+
import pandas as pd
|
| 2 |
import matplotlib.pyplot as plt
|
| 3 |
import io
|
| 4 |
import base64
|
|
|
|
| 9 |
from datetime import datetime, timedelta
|
| 10 |
import gradio as gr
|
| 11 |
import logging
|
| 12 |
+
from jinja2 import Template
|
| 13 |
|
| 14 |
# ===== εεθζ¨£εΌ =====
|
| 15 |
plt.rcParams['font.sans-serif'] = ['Microsoft JhengHei', 'Noto Sans TC', 'SimHei', 'Arial Unicode MS']
|
|
|
|
| 202 |
}
|
| 203 |
news_table = "<p>η‘ζ°θθ³ζ</p>"
|
| 204 |
|
| 205 |
+
# Convert news_summary to list of tuples to support iteration in template
|
| 206 |
+
news_summary = list(news_summary.items())
|
| 207 |
+
|
| 208 |
# --- εθ葨 ---
|
| 209 |
engagement_table = f"""
|
| 210 |
<table class="min-w-full bg-white border border-gray-200">
|
|
|
|
| 224 |
with open(template_path, encoding='utf-8') as f:
|
| 225 |
html_template = f.read()
|
| 226 |
|
| 227 |
+
template = Template(html_template)
|
| 228 |
+
html_content = template.render(
|
| 229 |
report_date=datetime.now().strftime('%Y-%m-%d %H:%M'),
|
| 230 |
engagement_table=engagement_table if engagement_table else "<p>ζͺζδΎδΊεζΈζ</p>",
|
| 231 |
news_summary=news_summary if news_summary else "<p>ζͺζδΎζ°θζθ¦</p>",
|
|
|
|
| 246 |
outputs=gr.HTML(),
|
| 247 |
title="2026 ι«ιεΈι·ιΈθθΌΏζ
εζ"
|
| 248 |
)
|
| 249 |
+
iface.launch(server_name="0.0.0.0", server_port=7860)
|