Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
#
|
| 204 |
if 'username' in st.session_state:
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 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(
|
| 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
|