Spaces:
Sleeping
Sleeping
Deploy Streamlit frontend with backend linkage
Browse files- streamlit_app.py +10 -5
streamlit_app.py
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
-
import requests
|
|
|
|
| 3 |
|
| 4 |
st.set_page_config(page_title="ExtraaLearn Lead Converter", layout="centered")
|
| 5 |
st.title("π ExtraaLearn Lead Conversion")
|
|
@@ -9,7 +16,7 @@ st.write("Enter lead details and click Predict.")
|
|
| 9 |
age = st.number_input("Age", 18, 100, 30)
|
| 10 |
visits = st.number_input("Website Visits", 0, 50, 1)
|
| 11 |
time_spent = st.number_input("Time Spent on Website (s)", 0, 5000, 300)
|
| 12 |
-
pages = st.number_input("
|
| 13 |
|
| 14 |
occ = st.selectbox("Current Occupation", ["Professional","Unemployed","Student"])
|
| 15 |
first_int = st.selectbox("First Interaction", ["Website","Mobile App"])
|
|
@@ -37,9 +44,7 @@ if st.button("Predict"):
|
|
| 37 |
"referral": int(referral),
|
| 38 |
"last_activity": last_act
|
| 39 |
}
|
| 40 |
-
|
| 41 |
-
url = f"https://huggingface.co/spaces/{'"$BACKEND_REPO"'}'/predict"
|
| 42 |
-
resp = requests.post(url, json=payload)
|
| 43 |
if resp.ok:
|
| 44 |
res = resp.json()
|
| 45 |
st.success(f"Conversion: {res['prediction']} (Prob: {res['probability']:.2f})")
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
# Redirect HOME so Streamlit can write config without root permissions
|
| 3 |
+
os.environ["HOME"] = "/tmp"
|
| 4 |
+
# Disable usage statistics to avoid writing to protected dirs
|
| 5 |
+
os.environ["STREAMLIT_GATHER_USAGE_STATS"] = "false"
|
| 6 |
+
|
| 7 |
import streamlit as st
|
| 8 |
+
import requests
|
| 9 |
+
import pandas as pd
|
| 10 |
|
| 11 |
st.set_page_config(page_title="ExtraaLearn Lead Converter", layout="centered")
|
| 12 |
st.title("π ExtraaLearn Lead Conversion")
|
|
|
|
| 16 |
age = st.number_input("Age", 18, 100, 30)
|
| 17 |
visits = st.number_input("Website Visits", 0, 50, 1)
|
| 18 |
time_spent = st.number_input("Time Spent on Website (s)", 0, 5000, 300)
|
| 19 |
+
pages = st.number_input("Page Views per Visit", 1, 20, 3)
|
| 20 |
|
| 21 |
occ = st.selectbox("Current Occupation", ["Professional","Unemployed","Student"])
|
| 22 |
first_int = st.selectbox("First Interaction", ["Website","Mobile App"])
|
|
|
|
| 44 |
"referral": int(referral),
|
| 45 |
"last_activity": last_act
|
| 46 |
}
|
| 47 |
+
resp = requests.post("https://huggingface.co/spaces/singhina/ExtraaLeanBackend/predict", json=payload)
|
|
|
|
|
|
|
| 48 |
if resp.ok:
|
| 49 |
res = resp.json()
|
| 50 |
st.success(f"Conversion: {res['prediction']} (Prob: {res['probability']:.2f})")
|