deadshot2003 commited on
Commit
a996b69
·
verified ·
1 Parent(s): b91a4d5

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -0
app.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import streamlit.components.v1 as components
3
+ from streamlit_extras.let_it_rain import rain
4
+
5
+ # Title of the app
6
+ st.title("A map of imperfect but perfect conversations")
7
+
8
+ # Define the map URLs
9
+ map_url_1 = "https://www.google.com/maps/d/embed?mid=1punqzU7t2tqZcLWxUXj966rITF0pmGQ&ehbc=2E312F"
10
+ map_url_2 = "https://www.google.com/maps/d/embed?mid=1tTBe_EuuCjzQu09Fx_cgom2M9h0hvQ8&ehbc=2E312F"
11
+
12
+ # Initialize the session state to track which map is displayed
13
+ if 'map_displayed' not in st.session_state:
14
+ st.session_state.map_displayed = map_url_1
15
+
16
+ # Define a function to switch the map
17
+ def switch_map():
18
+ if st.session_state.map_displayed == map_url_1:
19
+ st.session_state.map_displayed = map_url_2
20
+ else:
21
+ st.session_state.map_displayed = map_url_1
22
+
23
+ # Add a button to switch the map
24
+ if st.button("Switch Map"):
25
+ switch_map()
26
+
27
+ # Embed the selected map
28
+ iframe_html = f'''
29
+ <iframe src="{st.session_state.map_displayed}" width="100%" height="480" frameborder="0" style="border:0" allowfullscreen></iframe>
30
+ '''
31
+
32
+ # Render the iframe
33
+ components.html(iframe_html, height=500)
34
+
35
+ # Add the rain effect
36
+ rain(
37
+ emoji="🤓",
38
+ font_size=54,
39
+ falling_speed=5,
40
+ animation_length="infinite",
41
+ )