File size: 621 Bytes
40f9580
 
 
 
 
 
 
 
b8b8615
40f9580
b8b8615
 
 
40f9580
 
 
 
b8b8615
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import streamlit as st
import requests

st.title("✨ Quote Generator")
st.write("Click the button below to get a random inspirational quote.")

if st.button("Generate Quote"):
    try:
        response = requests.get("https://zenquotes.io/api/random")
        if response.status_code == 200:
            data = response.json()[0]
            quote = data["q"]
            author = data["a"]
            st.success(f"💡 *{quote}*  \n — {author}")
        else:
            st.error("⚠️ Could not fetch quote. Please try again later.")
    except Exception as e:
        st.error(f"⚠️ An error occurred: {e}")