Maheentouqeer1 commited on
Commit
ef07f13
·
verified ·
1 Parent(s): 60ed5ab

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -21
app.py CHANGED
@@ -606,32 +606,42 @@ with tab1:
606
  col_in, col_out = st.columns([1, 1], gap="large")
607
 
608
  with col_in:
609
- st.markdown('<div class="card"><div class="card-label">📝 Input Text</div>', unsafe_allow_html=True)
610
- user_text = st.text_area(
611
- "Article / Headline",
612
- height=240,
613
- placeholder="Paste your news article or headline here…\n\nExample:\n'BREAKING: Scientists discover miracle cure that Big Pharma is hiding!'",
614
- label_visibility="collapsed",
615
- )
616
 
617
- # sample buttons
618
- st.markdown('<div class="card-label" style="margin-top:1rem;">🧪 Try Samples</div>', unsafe_allow_html=True)
619
  s1, s2 = st.columns(2)
620
  with s1:
621
- if st.button("Real News Sample"):
622
- user_text = ("NASA's James Webb Space Telescope has captured the deepest infrared "
623
- "image of the universe, revealing thousands of galaxies that existed "
624
- "over 13 billion years ago. The milestone image was released in July 2022.")
625
- st.session_state["sample_text"] = user_text
 
 
 
626
  with s2:
627
- if st.button("Fake News Sample"):
628
- user_text = ("SHOCKING!! Scientists EXPOSED: drinking lemon water CURES cancer in 30 days! "
629
- "Big Pharma is HIDING this SECRET SHARE before it gets DELETED!!")
630
- st.session_state["sample_text"] = user_text
631
-
632
- if "sample_text" in st.session_state and not user_text:
633
- user_text = st.session_state["sample_text"]
 
634
 
 
 
 
 
 
 
 
 
 
 
635
  st.markdown('</div>', unsafe_allow_html=True)
636
 
637
  analyze_clicked = st.button("🔍 ANALYZE TEXT", key="analyze_btn")
 
606
  col_in, col_out = st.columns([1, 1], gap="large")
607
 
608
  with col_in:
609
+ # Init session state
610
+ if "news_text" not in st.session_state:
611
+ st.session_state["news_text"] = ""
 
 
 
 
612
 
613
+ # Sample buttons BEFORE text area so state is set on rerun
614
+ st.markdown('<div class="card-label">🧪 Try Samples</div>', unsafe_allow_html=True)
615
  s1, s2 = st.columns(2)
616
  with s1:
617
+ if st.button("Real News", key="real_sample"):
618
+ st.session_state["news_text"] = (
619
+ "NASA's James Webb Space Telescope has captured the deepest infrared "
620
+ "image of the universe ever taken, revealing thousands of galaxies that "
621
+ "existed over 13 billion years ago. The image was released in July 2022 "
622
+ "and marks a major milestone in space exploration and astrophysics."
623
+ )
624
+ st.rerun()
625
  with s2:
626
+ if st.button("⚠️ Fake News", key="fake_sample"):
627
+ st.session_state["news_text"] = (
628
+ "SHOCKING!! Scientists EXPOSED: drinking hot lemon water CURES cancer in "
629
+ "30 days! Big Pharma has been HIDING this SECRET for decades to protect "
630
+ "their profits. SHARE before it gets DELETED!! You WON'T BELIEVE what "
631
+ "they don't want you to know!!"
632
+ )
633
+ st.rerun()
634
 
635
+ st.markdown('<div class="card"><div class="card-label">📝 Input Text</div>', unsafe_allow_html=True)
636
+ user_text = st.text_area(
637
+ "Article / Headline",
638
+ value=st.session_state["news_text"],
639
+ height=220,
640
+ placeholder="Paste your news article or headline here…",
641
+ label_visibility="collapsed",
642
+ key="news_textarea",
643
+ )
644
+ st.session_state["news_text"] = user_text
645
  st.markdown('</div>', unsafe_allow_html=True)
646
 
647
  analyze_clicked = st.button("🔍 ANALYZE TEXT", key="analyze_btn")