Create main.py
Browse files
main.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import requests
|
| 3 |
+
|
| 4 |
+
st.set_page_config(page_title="Fact generator - Liux")
|
| 5 |
+
|
| 6 |
+
st.title("Fact generator")
|
| 7 |
+
|
| 8 |
+
# Fetch a random fact from the API
|
| 9 |
+
response = requests.get("https://uselessfacts.jsph.pl/random.json?language=en")
|
| 10 |
+
fact = response.json()["text"]
|
| 11 |
+
|
| 12 |
+
# Center the title and fact
|
| 13 |
+
col1, col2, col3 = st.columns([1, 10, 1])
|
| 14 |
+
with col2:
|
| 15 |
+
st.write(f"<h1 style='text-align: center;'>Fact generator</h1>", unsafe_allow_html=True)
|
| 16 |
+
st.write(f"<p style='text-align: center;'>{fact}</p>", unsafe_allow_html=True)
|