jokes / app.py
saoter's picture
Update app.py
4ea5061 verified
raw
history blame contribute delete
594 Bytes
import requests
import streamlit as st
def fetch_jokes():
url = 'https://v2.jokeapi.dev/joke/Any?safe-mode&type=single&amount=5'
response = requests.get(url)
data = response.json()
return data['jokes']
def display_jokes(jokes):
for joke in jokes:
with st.container():
st.markdown(f"**Category**: {joke['category']} | **Safe**: {'Yes' if joke['safe'] else 'No'}", unsafe_allow_html=True)
st.info(joke['joke'])
# Streamlit app
st.title('Joke Generator')
jokes = fetch_jokes()
st.write("Here are some jokes for you!")
display_jokes(jokes)