| import streamlit as st | |
| import requests | |
| st.set_page_config(page_title="") | |
| st.title("") | |
| # Fetch a random fact from the API | |
| response = requests.get("https://uselessfacts.jsph.pl/random.json?language=en") | |
| fact = response.json()["text"] | |
| # Center the title and fact | |
| col1, col2, col3 = st.columns([1, 10, 1]) | |
| with col2: | |
| st.write(f"<h1 style='text-align: center;'>Fact generator</h1>", unsafe_allow_html=True) | |
| st.write(f"<p style='text-align: center;'>{fact}</p>", unsafe_allow_html=True) |