File size: 915 Bytes
a0ed106
500053e
 
a0ed106
500053e
a0ed106
 
500053e
 
a0ed106
 
500053e
a0ed106
 
500053e
a0ed106
 
 
 
 
3818df8
 
a0ed106
3818df8
 
 
 
500053e
a0ed106
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# app.py
import streamlit as st
from guardian import fetch_headlines, fetch_full_article
from memes import article_to_meme

st.set_page_config(page_title="The Meme York Times", layout="wide")
st.title("📰➡️ Meme York Times")

# Sidebar controls
section = st.sidebar.selectbox("Section", ["world", "technology", "science", "culture"])
num      = st.sidebar.slider("Number of articles", 1, 10, 5)

with st.spinner("Fetching articles…"):
    articles = fetch_headlines(section, num)

for headline, url in articles:
    st.markdown(f"**{headline}**  \n[{url}]({url})")
    try:
        full_text = fetch_full_article(url)
        meme_url  = article_to_meme(full_text)

        # Display the meme image
        st.image(meme_url, use_column_width=True)

        # Display the raw meme URL below the image
        st.markdown(meme_url)

    except Exception as e:
        st.error(f"Error generating meme: {e}")