Spaces:
Running
Running
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +9 -9
src/streamlit_app.py
CHANGED
@@ -86,15 +86,15 @@ menu = st.sidebar.radio(
|
|
86 |
|
87 |
# 저장된 기사를 불러오는 함수
|
88 |
def load_saved_articles():
|
89 |
-
if os.path.exists('saved_articles/articles.json'):
|
90 |
-
with open('saved_articles/articles.json', 'r', encoding='utf-8') as f:
|
91 |
return json.load(f)
|
92 |
return []
|
93 |
|
94 |
# 기사를 저장하는 함수
|
95 |
def save_articles(articles):
|
96 |
-
os.makedirs('saved_articles', exist_ok=True)
|
97 |
-
with open('saved_articles/articles.json', 'w', encoding='utf-8') as f:
|
98 |
json.dump(articles, f, ensure_ascii=False, indent=2)
|
99 |
|
100 |
@st.cache_data
|
@@ -370,9 +370,9 @@ def perform_news_task(task_type, keyword, num_articles, file_prefix):
|
|
370 |
time.sleep(0.5) # 서버 부하 방지
|
371 |
|
372 |
# 결과 저장
|
373 |
-
os.makedirs('scheduled_news', exist_ok=True)
|
374 |
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
375 |
-
filename = f"scheduled_news/{file_prefix}_{task_type}_{timestamp}.json"
|
376 |
|
377 |
with open(filename, 'w', encoding='utf-8') as f:
|
378 |
json.dump(articles, f, ensure_ascii=False, indent=2)
|
@@ -1095,13 +1095,13 @@ elif menu == "뉴스 기사 예약하기":
|
|
1095 |
)
|
1096 |
|
1097 |
# 수집된 파일 보기
|
1098 |
-
if os.path.exists('scheduled_news'):
|
1099 |
-
files = [f for f in os.listdir('scheduled_news') if f.endswith('.json')]
|
1100 |
if files:
|
1101 |
st.subheader("수집된 파일 열기")
|
1102 |
selected_file = st.selectbox("파일 선택", files, index=len(files)-1)
|
1103 |
if selected_file and st.button("파일 내용 보기"):
|
1104 |
-
with open(os.path.join('scheduled_news', selected_file), 'r', encoding='utf-8') as f:
|
1105 |
articles = json.load(f)
|
1106 |
|
1107 |
st.write(f"**파일명:** {selected_file}")
|
|
|
86 |
|
87 |
# 저장된 기사를 불러오는 함수
|
88 |
def load_saved_articles():
|
89 |
+
if os.path.exists('/tmp/saved_articles/articles.json'):
|
90 |
+
with open('/tmp/saved_articles/articles.json', 'r', encoding='utf-8') as f:
|
91 |
return json.load(f)
|
92 |
return []
|
93 |
|
94 |
# 기사를 저장하는 함수
|
95 |
def save_articles(articles):
|
96 |
+
os.makedirs('/tmp/saved_articles', exist_ok=True)
|
97 |
+
with open('/tmp/saved_articles/articles.json', 'w', encoding='utf-8') as f:
|
98 |
json.dump(articles, f, ensure_ascii=False, indent=2)
|
99 |
|
100 |
@st.cache_data
|
|
|
370 |
time.sleep(0.5) # 서버 부하 방지
|
371 |
|
372 |
# 결과 저장
|
373 |
+
os.makedirs('/tmp/scheduled_news', exist_ok=True)
|
374 |
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
375 |
+
filename = f"/tmp/scheduled_news/{file_prefix}_{task_type}_{timestamp}.json"
|
376 |
|
377 |
with open(filename, 'w', encoding='utf-8') as f:
|
378 |
json.dump(articles, f, ensure_ascii=False, indent=2)
|
|
|
1095 |
)
|
1096 |
|
1097 |
# 수집된 파일 보기
|
1098 |
+
if os.path.exists('/tmp/scheduled_news'):
|
1099 |
+
files = [f for f in os.listdir('/tmp/scheduled_news') if f.endswith('.json')]
|
1100 |
if files:
|
1101 |
st.subheader("수집된 파일 열기")
|
1102 |
selected_file = st.selectbox("파일 선택", files, index=len(files)-1)
|
1103 |
if selected_file and st.button("파일 내용 보기"):
|
1104 |
+
with open(os.path.join('/tmp/scheduled_news', selected_file), 'r', encoding='utf-8') as f:
|
1105 |
articles = json.load(f)
|
1106 |
|
1107 |
st.write(f"**파일명:** {selected_file}")
|