Ashendilantha commited on
Commit
33dbcf5
·
verified ·
1 Parent(s): 9b6c6b1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -14
app.py CHANGED
@@ -8,23 +8,18 @@ from nltk.stem import WordNetLemmatizer
8
  from transformers import pipeline
9
  from PIL import Image
10
 
11
- # Move set_page_config to the first line with a default layout
12
- st.set_page_config(page_title="News Classifier", page_icon="📰", layout="wide")
13
-
14
- # Function to detect device type
15
- def detect_device():
16
- user_agent = st.experimental_get_query_params().get("user_agent", [""])[0]
17
- if "mobi" in user_agent.lower():
18
- return "Mobile"
19
- return "PC"
20
-
21
- # Ask user for device preference (only if not already set)
22
  if "device_type" not in st.session_state:
23
- st.session_state.device_type = st.radio("Are you using a mobile device or a PC?", ["Mobile", "PC"])
 
 
 
24
 
25
- # Adjust layout based on user selection
26
  if st.session_state.device_type == "Mobile":
27
- st.set_page_config(layout="centered") # Not needed if already set, but here for clarity
 
 
28
 
29
  # Continue with the rest of the code
30
  nltk.download('stopwords')
 
8
  from transformers import pipeline
9
  from PIL import Image
10
 
11
+ # Check if device type is already stored
 
 
 
 
 
 
 
 
 
 
12
  if "device_type" not in st.session_state:
13
+ # Ask user for device type
14
+ device_type = st.radio("Are you using a mobile device or a PC?", ["Mobile", "PC"])
15
+ st.session_state.device_type = device_type
16
+ st.experimental_rerun() # Refresh the app to apply layout change
17
 
18
+ # Set layout based on user selection
19
  if st.session_state.device_type == "Mobile":
20
+ st.set_page_config(page_title="News Classifier", page_icon="📰", layout="centered")
21
+ else:
22
+ st.set_page_config(page_title="News Classifier", page_icon="📰", layout="wide")
23
 
24
  # Continue with the rest of the code
25
  nltk.download('stopwords')