singhina commited on
Commit
2603cfa
Β·
1 Parent(s): e1da973

Fix Streamlit async loop & permission issues + backend linkage

Browse files
Files changed (2) hide show
  1. .streamlit/config.toml +3 -0
  2. app.py +6 -4
.streamlit/config.toml ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ [global]
2
+ disableUsageStats = true
3
+ disableInstallationID = true
app.py CHANGED
@@ -1,11 +1,13 @@
1
  import os
2
- # Redirect HOME so Streamlit can write config without root permissions
3
  os.environ["HOME"] = "/tmp"
 
4
  os.environ["STREAMLIT_GATHER_USAGE_STATS"] = "false"
 
5
  os.environ["STREAMLIT_CONFIG_DIR"] = "/tmp/.streamlit"
6
  os.environ["STREAMLIT_CACHE_DIR"] = "/tmp/.streamlit"
7
 
8
- # Patch asyncio event loop to avoid RuntimeError in Streamlit
9
  import nest_asyncio
10
  nest_asyncio.apply()
11
 
@@ -13,16 +15,16 @@ import streamlit as st
13
  import requests
14
  import pandas as pd
15
 
 
16
  st.set_page_config(page_title="ExtraaLearn Lead Converter", layout="centered")
17
  st.title("πŸŽ“ ExtraaLearn Lead Conversion")
18
  st.write("Enter lead details and click Predict.")
19
 
20
- # Input widgets
21
  age = st.number_input("Age", 18, 100, 30)
22
  visits = st.number_input("Website Visits", 0, 50, 1)
23
  time_spent = st.number_input("Time Spent on Website (s)", 0, 5000, 300)
24
  pages = st.number_input("Page Views per Visit", 1, 20, 3)
25
-
26
  occ = st.selectbox("Current Occupation", ["Professional","Unemployed","Student"])
27
  first_int = st.selectbox("First Interaction", ["Website","Mobile App"])
28
  profile = st.selectbox("Profile Completed", ["Low","Medium","High"])
 
1
  import os
2
+ # Redirect HOME so Streamlit writes under /tmp
3
  os.environ["HOME"] = "/tmp"
4
+ # Disable usage stats
5
  os.environ["STREAMLIT_GATHER_USAGE_STATS"] = "false"
6
+ # Use tmp for config/cache
7
  os.environ["STREAMLIT_CONFIG_DIR"] = "/tmp/.streamlit"
8
  os.environ["STREAMLIT_CACHE_DIR"] = "/tmp/.streamlit"
9
 
10
+ # Patch asyncio loop to avoid RuntimeError
11
  import nest_asyncio
12
  nest_asyncio.apply()
13
 
 
15
  import requests
16
  import pandas as pd
17
 
18
+ # Page config
19
  st.set_page_config(page_title="ExtraaLearn Lead Converter", layout="centered")
20
  st.title("πŸŽ“ ExtraaLearn Lead Conversion")
21
  st.write("Enter lead details and click Predict.")
22
 
23
+ # Inputs
24
  age = st.number_input("Age", 18, 100, 30)
25
  visits = st.number_input("Website Visits", 0, 50, 1)
26
  time_spent = st.number_input("Time Spent on Website (s)", 0, 5000, 300)
27
  pages = st.number_input("Page Views per Visit", 1, 20, 3)
 
28
  occ = st.selectbox("Current Occupation", ["Professional","Unemployed","Student"])
29
  first_int = st.selectbox("First Interaction", ["Website","Mobile App"])
30
  profile = st.selectbox("Profile Completed", ["Low","Medium","High"])