awacke1 commited on
Commit
cd61036
Β·
verified Β·
1 Parent(s): 8670e64

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -18
app.py CHANGED
@@ -14,14 +14,13 @@ from urllib.parse import quote
14
  import base64
15
  import io
16
 
17
- # App Configuration
18
- Site_Name = 'πŸ€–πŸ§ MMO Chat BrainπŸ“πŸ”¬' # Default, will be updated with username
19
- title = "πŸ€–πŸ§ MMO Chat BrainπŸ“πŸ”¬" # Default, will be updated
20
  icons = 'πŸ€–πŸ§ πŸ”¬πŸ“'
21
  START_ROOM = "Sector 🌌"
22
 
 
23
  st.set_page_config(
24
- page_title=title,
25
  page_icon=icons,
26
  layout="wide",
27
  initial_sidebar_state="auto"
@@ -200,12 +199,11 @@ async def run_websocket_server():
200
  await server.wait_closed()
201
 
202
  def create_streamlit_interface():
203
- # Update Site_Name and title with current username
204
  if 'username' in st.session_state:
205
- global Site_Name, title
206
- Site_Name = f"πŸ€–πŸ§ MMO {st.session_state.username}πŸ“πŸ”¬"
207
- title = f"πŸ€–πŸ§ MMO {st.session_state.username}πŸ“πŸ”¬"
208
- st.set_page_config(page_title=title) # Update page title
209
 
210
  st.markdown("""
211
  <style>
@@ -233,7 +231,7 @@ def create_streamlit_interface():
233
  </script>
234
  """, unsafe_allow_html=True)
235
 
236
- st.title(f"{Site_Name}")
237
  st.markdown(f"Welcome to {START_ROOM} - chat, vote, upload, and enjoy! πŸŽ‰")
238
 
239
  # Initialize client ID and username
@@ -242,10 +240,6 @@ def create_streamlit_interface():
242
  if 'username' not in st.session_state:
243
  available_names = [name for name in FUN_USERNAMES if not any(f"{name} has joined" in line for line in load_chat().split('\n'))]
244
  st.session_state.username = random.choice(available_names) if available_names else random.choice(FUN_USERNAMES)
245
- # Update title immediately after setting initial username
246
- Site_Name = f"πŸ€–πŸ§ MMO {st.session_state.username}πŸ“πŸ”¬"
247
- title = f"πŸ€–πŸ§ MMO {st.session_state.username}πŸ“πŸ”¬"
248
- st.set_page_config(page_title=title)
249
 
250
  # Session state initialization
251
  if 'refresh_rate' not in st.session_state:
@@ -276,10 +270,6 @@ def create_streamlit_interface():
276
  if new_username and new_username != st.session_state.username:
277
  save_chat_entry("System 🌟", f"{st.session_state.username} changed name to {new_username}")
278
  st.session_state.username = new_username
279
- # Update title when name changes
280
- Site_Name = f"πŸ€–πŸ§ MMO {st.session_state.username}πŸ“πŸ”¬"
281
- title = f"πŸ€–πŸ§ MMO {st.session_state.username}πŸ“πŸ”¬"
282
- st.set_page_config(page_title=title)
283
  st.rerun()
284
 
285
  # Message input
 
14
  import base64
15
  import io
16
 
17
+ # Initial App Configuration (static)
 
 
18
  icons = 'πŸ€–πŸ§ πŸ”¬πŸ“'
19
  START_ROOM = "Sector 🌌"
20
 
21
+ # Set page config once at the top
22
  st.set_page_config(
23
+ page_title="πŸ€–πŸ§ MMO Chat BrainπŸ“πŸ”¬", # Initial static title
24
  page_icon=icons,
25
  layout="wide",
26
  initial_sidebar_state="auto"
 
199
  await server.wait_closed()
200
 
201
  def create_streamlit_interface():
202
+ # Dynamic title based on username
203
  if 'username' in st.session_state:
204
+ dynamic_title = f"πŸ€–πŸ§ MMO {st.session_state.username}πŸ“πŸ”¬"
205
+ else:
206
+ dynamic_title = "πŸ€–πŸ§ MMO Chat BrainπŸ“πŸ”¬"
 
207
 
208
  st.markdown("""
209
  <style>
 
231
  </script>
232
  """, unsafe_allow_html=True)
233
 
234
+ st.title(dynamic_title) # Use dynamic title here
235
  st.markdown(f"Welcome to {START_ROOM} - chat, vote, upload, and enjoy! πŸŽ‰")
236
 
237
  # Initialize client ID and username
 
240
  if 'username' not in st.session_state:
241
  available_names = [name for name in FUN_USERNAMES if not any(f"{name} has joined" in line for line in load_chat().split('\n'))]
242
  st.session_state.username = random.choice(available_names) if available_names else random.choice(FUN_USERNAMES)
 
 
 
 
243
 
244
  # Session state initialization
245
  if 'refresh_rate' not in st.session_state:
 
270
  if new_username and new_username != st.session_state.username:
271
  save_chat_entry("System 🌟", f"{st.session_state.username} changed name to {new_username}")
272
  st.session_state.username = new_username
 
 
 
 
273
  st.rerun()
274
 
275
  # Message input