Lokiiparihar commited on
Commit
1e6ae11
·
verified ·
1 Parent(s): c0232cb

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +8 -3
src/streamlit_app.py CHANGED
@@ -46,21 +46,24 @@ input_data = {
46
  **product_type_features
47
  }
48
 
49
- # --- API CALL ---
50
  if st.button("Predict Sales"):
51
  with st.spinner("Fetching prediction from backend..."):
52
  try:
53
  response = requests.post(
54
- "https://lokiiparihar-SuperkartBackendModalDeploy-XGBoost.hf.space/predict",
55
  json=input_data
56
  )
57
  if response.status_code == 200:
58
  try:
59
  result = response.json()
 
 
 
60
  prediction = result.get("prediction", None)
61
  except ValueError:
62
- # Handle raw text response
63
  prediction = response.text
 
 
64
 
65
  try:
66
  prediction = float(prediction)
@@ -72,3 +75,5 @@ if st.button("Predict Sales"):
72
  st.text(response.text)
73
  except Exception as e:
74
  st.error(f"❌ Request failed: {e}")
 
 
 
46
  **product_type_features
47
  }
48
 
 
49
  if st.button("Predict Sales"):
50
  with st.spinner("Fetching prediction from backend..."):
51
  try:
52
  response = requests.post(
53
+ "https://lokiiparihar-SuperkartBackendModalDeploy-XGBoost.hf.space/predict,
54
  json=input_data
55
  )
56
  if response.status_code == 200:
57
  try:
58
  result = response.json()
59
+ st.subheader("🔍 Raw Backend Response")
60
+ st.json(result) # SHOW FULL JSON RETURNED
61
+
62
  prediction = result.get("prediction", None)
63
  except ValueError:
 
64
  prediction = response.text
65
+ st.warning("⚠ Backend did not return JSON, showing raw text:")
66
+ st.code(prediction)
67
 
68
  try:
69
  prediction = float(prediction)
 
75
  st.text(response.text)
76
  except Exception as e:
77
  st.error(f"❌ Request failed: {e}")
78
+
79
+