Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,83 +2,88 @@ import streamlit as st
|
|
| 2 |
import pandas as pd
|
| 3 |
import folium
|
| 4 |
from streamlit_folium import folium_static
|
| 5 |
-
|
| 6 |
|
| 7 |
-
#
|
|
|
|
|
|
|
| 8 |
st.set_page_config(page_title="Wild Bill vs Buffalo Bill", page_icon="π€ ", layout="wide")
|
| 9 |
|
| 10 |
-
#
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
... # (The rest of the Wild Bill story remains the same)
|
| 20 |
-
"""
|
| 21 |
-
|
| 22 |
-
buffalo_bill_story = """
|
| 23 |
-
# 𦬠Buffalo Bill Cody: The Showman of the West
|
| 24 |
-
|
| 25 |
-
## 1. π Early Life
|
| 26 |
-
- πΌ Born William Frederick Cody on February 26, 1846, in Le Claire, Iowa
|
| 27 |
-
- π Began riding horses at a young age
|
| 28 |
-
- π Worked as a Pony Express rider at age 14
|
| 29 |
-
|
| 30 |
-
... # (The rest of the Buffalo Bill story remains the same)
|
| 31 |
-
"""
|
| 32 |
-
|
| 33 |
-
# Sidebar
|
| 34 |
-
st.sidebar.title("π Key Locations & Events")
|
| 35 |
-
|
| 36 |
-
st.sidebar.markdown("""
|
| 37 |
-
## Wild Bill Hickok
|
| 38 |
-
- π‘ Homer, Illinois (Birth)
|
| 39 |
-
- π½ Rock Creek Station, Nebraska
|
| 40 |
-
- π Abilene, Kansas
|
| 41 |
-
- ποΈ Cheyenne, Wyoming
|
| 42 |
-
- πͺ Deadwood, South Dakota (Death)
|
| 43 |
-
|
| 44 |
-
## Buffalo Bill Cody
|
| 45 |
-
- π‘ Le Claire, Iowa (Birth)
|
| 46 |
-
- π½ North Platte, Nebraska
|
| 47 |
-
- ποΈ Cody, Wyoming
|
| 48 |
-
- π Denver, Colorado
|
| 49 |
-
- ποΈ Denver, Colorado (Death)
|
| 50 |
-
""")
|
| 51 |
|
| 52 |
-
|
| 53 |
-
st.title("π€ Wild Bill Hickok vs Buffalo Bill Cody: A Tale of Two Western Legends")
|
| 54 |
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
st.markdown(wild_bill_story)
|
| 59 |
|
| 60 |
-
|
|
|
|
|
|
|
| 61 |
st.markdown(buffalo_bill_story)
|
| 62 |
|
| 63 |
-
#
|
| 64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
m = folium.Map(location=[41, -100], zoom_start=4)
|
| 68 |
|
| 69 |
-
#
|
| 70 |
locations = [
|
| 71 |
-
("Homer, IL", 40.0356, -87.9506, "Wild Bill
|
| 72 |
-
("Rock Creek Station, NE", 40.1116, -97.0564, "McCanles Massacre
|
| 73 |
-
("Abilene, KS", 38.9172, -97.2137, "Wild Bill
|
| 74 |
-
("Cheyenne, WY", 41.1400, -104.8202, "Wild Bill's brief
|
| 75 |
-
("Deadwood, SD", 44.3767, -103.7296, "Wild Bill's
|
| 76 |
-
("Le Claire, IA", 41.5978, -90.3485, "Buffalo Bill's
|
| 77 |
-
("North Platte, NE", 41.1239, -100.7654, "Buffalo Bill's
|
| 78 |
-
("Cody, WY", 44.5263, -109.0565, "
|
| 79 |
-
("Denver, CO", 39.7392, -104.9903, "Buffalo Bill's
|
| 80 |
]
|
| 81 |
|
|
|
|
| 82 |
for name, lat, lon, desc in locations:
|
| 83 |
folium.Marker(
|
| 84 |
[lat, lon],
|
|
@@ -86,98 +91,44 @@ for name, lat, lon, desc in locations:
|
|
| 86 |
tooltip=name
|
| 87 |
).add_to(m)
|
| 88 |
|
| 89 |
-
#
|
| 90 |
folium_static(m)
|
| 91 |
|
| 92 |
-
#
|
| 93 |
-
st.subheader("β³ Animated Timeline")
|
| 94 |
-
|
| 95 |
-
timeline_component = """
|
| 96 |
-
import React, { useState, useEffect } from 'react';
|
| 97 |
-
|
| 98 |
-
const Timeline = () => {
|
| 99 |
-
const [year, setYear] = useState(1837);
|
| 100 |
-
const [event, setEvent] = useState('');
|
| 101 |
-
|
| 102 |
-
const events = {
|
| 103 |
-
1837: "Wild Bill Hickok born",
|
| 104 |
-
1846: "Buffalo Bill Cody born",
|
| 105 |
-
1861: "Wild Bill involved in McCanles Massacre",
|
| 106 |
-
1867: "Buffalo Bill begins hunting buffalo for Kansas Pacific Railroad",
|
| 107 |
-
1871: "Wild Bill becomes marshal of Abilene, Kansas",
|
| 108 |
-
1872: "Buffalo Bill awarded Medal of Honor",
|
| 109 |
-
1876: "Wild Bill assassinated in Deadwood",
|
| 110 |
-
1883: "Buffalo Bill's Wild West show debuts",
|
| 111 |
-
1893: "Buffalo Bill performs at Chicago World's Fair",
|
| 112 |
-
1917: "Buffalo Bill dies in Denver"
|
| 113 |
-
};
|
| 114 |
-
|
| 115 |
-
useEffect(() => {
|
| 116 |
-
const timer = setInterval(() => {
|
| 117 |
-
setYear(prevYear => {
|
| 118 |
-
const newYear = prevYear + 1;
|
| 119 |
-
if (newYear > 1917) return 1837;
|
| 120 |
-
return newYear;
|
| 121 |
-
});
|
| 122 |
-
}, 1000);
|
| 123 |
-
|
| 124 |
-
return () => clearInterval(timer);
|
| 125 |
-
}, []);
|
| 126 |
-
|
| 127 |
-
useEffect(() => {
|
| 128 |
-
setEvent(events[year] || '');
|
| 129 |
-
}, [year]);
|
| 130 |
-
|
| 131 |
-
return (
|
| 132 |
-
<div className="timeline">
|
| 133 |
-
<h2 className="text-2xl font-bold mb-4">Year: {year}</h2>
|
| 134 |
-
<p className="text-lg">{event}</p>
|
| 135 |
-
</div>
|
| 136 |
-
);
|
| 137 |
-
};
|
| 138 |
-
|
| 139 |
-
export default Timeline;
|
| 140 |
-
"""
|
| 141 |
-
|
| 142 |
-
# Use the html component to render the React Timeline
|
| 143 |
-
html(
|
| 144 |
-
f"""
|
| 145 |
-
<div id="react-root"></div>
|
| 146 |
-
<script src="https://unpkg.com/react@17/umd/react.production.min.js"></script>
|
| 147 |
-
<script src="https://unpkg.com/react-dom@17/umd/react-dom.production.min.js"></script>
|
| 148 |
-
<script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
|
| 149 |
-
<script type="text/babel">
|
| 150 |
-
{timeline_component}
|
| 151 |
-
ReactDOM.render(<Timeline />, document.getElementById('react-root'));
|
| 152 |
-
</script>
|
| 153 |
-
"""
|
| 154 |
-
)
|
| 155 |
-
|
| 156 |
-
# Comparison table
|
| 157 |
st.subheader("π Side-by-Side Comparison")
|
| 158 |
-
|
| 159 |
comparison_data = {
|
| 160 |
"Aspect": ["Birth Year", "Death Year", "Nickname Origin", "Primary Occupation", "Famous For", "Colorado Connection", "South Dakota Connection"],
|
| 161 |
-
"Wild Bill Hickok": ["1837", "1876", "Unclear, possibly
|
| 162 |
-
"Buffalo Bill Cody": ["1846", "1917", "Buffalo hunting
|
| 163 |
}
|
| 164 |
|
|
|
|
| 165 |
df = pd.DataFrame(comparison_data)
|
| 166 |
st.table(df)
|
| 167 |
|
| 168 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 169 |
st.markdown("""
|
| 170 |
## π
Conclusion: Legends of the West
|
| 171 |
|
| 172 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 173 |
|
| 174 |
-
|
| 175 |
-
- πͺ **Buffalo Bill Cody** transformed his real-life adventures into grand spectacles, sharing his vision of the West with audiences around the world.
|
| 176 |
|
| 177 |
-
|
| 178 |
""")
|
| 179 |
|
| 180 |
-
#
|
| 181 |
if __name__ == "__main__":
|
| 182 |
st.sidebar.markdown("---")
|
| 183 |
-
st.sidebar.markdown("Created with β€οΈ using Streamlit")
|
|
|
|
| 2 |
import pandas as pd
|
| 3 |
import folium
|
| 4 |
from streamlit_folium import folium_static
|
| 5 |
+
import extra_streamlit_components as stx
|
| 6 |
|
| 7 |
+
# π€ Howdy, partner! Welcome to the Wild West of coding! π΅
|
| 8 |
+
|
| 9 |
+
# π Set the stage for our grand performance
|
| 10 |
st.set_page_config(page_title="Wild Bill vs Buffalo Bill", page_icon="π€ ", layout="wide")
|
| 11 |
|
| 12 |
+
# π§ Initialize our app's memory (it's not whiskey, I promise!)
|
| 13 |
+
if 'page' not in st.session_state:
|
| 14 |
+
st.session_state.page = 'home'
|
| 15 |
+
|
| 16 |
+
# πͺ Cookie Manager: Because even cowboys need snacks
|
| 17 |
+
@st.cache_resource
|
| 18 |
+
def get_manager():
|
| 19 |
+
return stx.CookieManager()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
|
| 21 |
+
cookie_manager = get_manager()
|
|
|
|
| 22 |
|
| 23 |
+
# π All aboard the Router Express! Next stop: Destination Page
|
| 24 |
+
@st.cache_resource(hash_funcs={"_thread.RLock": lambda _: None})
|
| 25 |
+
def init_router():
|
| 26 |
+
return stx.Router({"/home": home, "/wild-bill": wild_bill, "/buffalo-bill": buffalo_bill})
|
| 27 |
|
| 28 |
+
# π‘ Home on the range
|
| 29 |
+
def home():
|
| 30 |
+
st.title("π€ Wild Bill Hickok vs Buffalo Bill Cody: A Tale of Two Western Legends")
|
| 31 |
+
st.write("Welcome to our interactive dime novel! Choose a character to explore their story.")
|
| 32 |
+
|
| 33 |
+
# π« Wild Bill's saloon (careful, he's a quick draw!)
|
| 34 |
+
def wild_bill():
|
| 35 |
+
st.title("π« Wild Bill Hickok: The Legendary Gunslinger")
|
| 36 |
st.markdown(wild_bill_story)
|
| 37 |
|
| 38 |
+
# πͺ Step right up to Buffalo Bill's Wild West Show!
|
| 39 |
+
def buffalo_bill():
|
| 40 |
+
st.title("𦬠Buffalo Bill Cody: The Showman of the West")
|
| 41 |
st.markdown(buffalo_bill_story)
|
| 42 |
|
| 43 |
+
# π All aboard! The Router is leaving the station!
|
| 44 |
+
router = init_router()
|
| 45 |
+
|
| 46 |
+
# π§ Navigation: Don't get lost in the prairie!
|
| 47 |
+
chosen_id = stx.tab_bar(data=[
|
| 48 |
+
stx.TabBarItemData(id="home", title="Home", description="Start here"),
|
| 49 |
+
stx.TabBarItemData(id="wild-bill", title="Wild Bill", description="Explore Wild Bill's story"),
|
| 50 |
+
stx.TabBarItemData(id="buffalo-bill", title="Buffalo Bill", description="Discover Buffalo Bill's adventures"),
|
| 51 |
+
], default="home")
|
| 52 |
+
|
| 53 |
+
# π Giddy up to the chosen page!
|
| 54 |
+
router.route(f"/{chosen_id}")
|
| 55 |
+
|
| 56 |
+
# πΊοΈ You are here (in case you got lost in a saloon)
|
| 57 |
+
router.show_route_view()
|
| 58 |
+
|
| 59 |
+
# π°οΈ Remember the last saloon... err, page you visited
|
| 60 |
+
cookie_manager.set("last_page", chosen_id)
|
| 61 |
|
| 62 |
+
# π Reveal the secrets of your past (visits)
|
| 63 |
+
st.sidebar.write(f"Last visited: {cookie_manager.get('last_page')}")
|
| 64 |
+
|
| 65 |
+
# π’ Put your boots on, we're going on a story adventure!
|
| 66 |
+
story_progress = stx.stepper_bar(steps=["Early Life", "Rise to Fame", "Notable Feats", "Legacy"])
|
| 67 |
+
st.sidebar.info(f"Story Progress: Phase #{story_progress}")
|
| 68 |
+
|
| 69 |
+
# πΊοΈ Map: Because even legends need GPS sometimes
|
| 70 |
+
st.subheader("πΊοΈ Journey Through the Wild West")
|
| 71 |
m = folium.Map(location=[41, -100], zoom_start=4)
|
| 72 |
|
| 73 |
+
# π Mark the spots where our legends left their boot prints
|
| 74 |
locations = [
|
| 75 |
+
("Homer, IL", 40.0356, -87.9506, "Wild Bill's first rodeo (birthplace)"),
|
| 76 |
+
("Rock Creek Station, NE", 40.1116, -97.0564, "Wild Bill's wild time (McCanles Massacre)"),
|
| 77 |
+
("Abilene, KS", 38.9172, -97.2137, "Wild Bill's badge-wearing days"),
|
| 78 |
+
("Cheyenne, WY", 41.1400, -104.8202, "Wild Bill's brief sheriff showdown"),
|
| 79 |
+
("Deadwood, SD", 44.3767, -103.7296, "Wild Bill's last poker game π’"),
|
| 80 |
+
("Le Claire, IA", 41.5978, -90.3485, "Buffalo Bill's first 'Yee-haw!' (birthplace)"),
|
| 81 |
+
("North Platte, NE", 41.1239, -100.7654, "Buffalo Bill's home on the range"),
|
| 82 |
+
("Cody, WY", 44.5263, -109.0565, "Buffalo Bill's namesake town (no buffaloes were harmed)"),
|
| 83 |
+
("Denver, CO", 39.7392, -104.9903, "Buffalo Bill's final bow π")
|
| 84 |
]
|
| 85 |
|
| 86 |
+
# π¨ Paint the town red... or at least mark it on the map
|
| 87 |
for name, lat, lon, desc in locations:
|
| 88 |
folium.Marker(
|
| 89 |
[lat, lon],
|
|
|
|
| 91 |
tooltip=name
|
| 92 |
).add_to(m)
|
| 93 |
|
| 94 |
+
# π Showcase our masterpiece map
|
| 95 |
folium_static(m)
|
| 96 |
|
| 97 |
+
# π Compare our legends (no gunslingers were harmed in the making of this table)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 98 |
st.subheader("π Side-by-Side Comparison")
|
|
|
|
| 99 |
comparison_data = {
|
| 100 |
"Aspect": ["Birth Year", "Death Year", "Nickname Origin", "Primary Occupation", "Famous For", "Colorado Connection", "South Dakota Connection"],
|
| 101 |
+
"Wild Bill Hickok": ["1837", "1876", "Unclear, possibly his wild nose π", "Lawman, Gunfighter", "Quick Draw McGraw IRL", "Visited (probably for the beer πΊ)", "Died in Deadwood (worst poker game ever)"],
|
| 102 |
+
"Buffalo Bill Cody": ["1846", "1917", "Buffalo hunting (not actual buffaloes)", "Showman, Scout", "Wild West Show (wilder than spring break)", "Home in Denver (loved the mountains)", "Performed shows (to rival Deadwood's saloons)"]
|
| 103 |
}
|
| 104 |
|
| 105 |
+
# π Let the comparison show begin!
|
| 106 |
df = pd.DataFrame(comparison_data)
|
| 107 |
st.table(df)
|
| 108 |
|
| 109 |
+
# πΌοΈ A picture's worth a thousand yeehaws!
|
| 110 |
+
st.subheader("Wild West Imagery")
|
| 111 |
+
image_url = "https://upload.wikimedia.org/wikipedia/commons/thumb/d/d6/Wild_Bill_Hickok_1869.jpg/800px-Wild_Bill_Hickok_1869.jpg"
|
| 112 |
+
stx.bouncing_image(image_source=image_url, animate=True, animation_time=1500, height=300, width=200)
|
| 113 |
+
|
| 114 |
+
# π
Ride off into the sunset with our conclusion
|
| 115 |
st.markdown("""
|
| 116 |
## π
Conclusion: Legends of the West
|
| 117 |
|
| 118 |
+
Yeehaw! We've corralled the tales of two of the wildest cowboys to ever roam the American frontier! π€
|
| 119 |
+
|
| 120 |
+
- π« **Wild Bill Hickok**: The man, the myth, the mustache! He lived fast, died young, and left a good-looking corpse (with a really bad poker hand).
|
| 121 |
+
|
| 122 |
+
- πͺ **Buffalo Bill Cody**: The original showman who put the 'wild' in Wild West! He turned frontier life into a circus... literally!
|
| 123 |
+
|
| 124 |
+
These two buckaroos shaped the West faster than a tumbleweek πΏ rollin' in a tornado! Their legacy is as enduring as the smell of a cowboy's boots after a long cattle drive. ππ¨
|
| 125 |
|
| 126 |
+
So next time you're sipping sarsaparilla π₯€ in a saloon, tip your hat π€ to Wild Bill and Buffalo Bill - the OG influencers of the American West!
|
|
|
|
| 127 |
|
| 128 |
+
Remember, in the words of the great philosopher Woody from Toy Story: "There's a snake in my boot!" ππ’ (Okay, maybe that's not relevant, but it's still a great quote!)
|
| 129 |
""")
|
| 130 |
|
| 131 |
+
# π¬ That's all, folks!
|
| 132 |
if __name__ == "__main__":
|
| 133 |
st.sidebar.markdown("---")
|
| 134 |
+
st.sidebar.markdown("Created with β€οΈ and a lot of π€ using Streamlit")
|