Lokiiparihar commited on
Commit
24a44b0
·
verified ·
1 Parent(s): 97b2485

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +7 -6
src/streamlit_app.py CHANGED
@@ -1,11 +1,10 @@
1
-
2
  import streamlit as st
3
  import requests
4
 
5
  # --- Streamlit UI config ---
6
  st.set_page_config(page_title="SuperKart Sales Prediction", layout="centered")
7
 
8
- st.title(" SuperKart Sales Prediction")
9
  st.write("Enter product and store features below to get a sales forecast.")
10
 
11
  # --- INPUT FIELDS ---
@@ -57,20 +56,22 @@ if st.button("Predict Sales"):
57
  if response.status_code == 200:
58
  try:
59
  result = response.json()
60
- st.subheader(" Raw Backend Response")
 
 
61
  prediction = result.get("Predicted_Sales", None)
62
  except ValueError:
63
  prediction = response.text
64
- st.warning(" Backend did not return JSON, showing raw text:")
65
  st.code(prediction)
66
 
67
  try:
68
  prediction = float(prediction)
69
  st.success(f"Predicted Sales: **{prediction:.2f} units**")
70
  except (ValueError, TypeError):
71
- st.error(f"Could not convert prediction to number: {prediction}")
72
  else:
73
  st.error(f"API Error: Status code {response.status_code}")
74
  st.text(response.text)
75
  except Exception as e:
76
- st.error(f"Request failed: {e}")
 
 
1
  import streamlit as st
2
  import requests
3
 
4
  # --- Streamlit UI config ---
5
  st.set_page_config(page_title="SuperKart Sales Prediction", layout="centered")
6
 
7
+ st.title("🛒 SuperKart Sales Prediction")
8
  st.write("Enter product and store features below to get a sales forecast.")
9
 
10
  # --- INPUT FIELDS ---
 
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("Predicted_Sales", 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)
70
  st.success(f"Predicted Sales: **{prediction:.2f} units**")
71
  except (ValueError, TypeError):
72
+ st.error(f" Could not convert prediction to number: {prediction}")
73
  else:
74
  st.error(f"API Error: Status code {response.status_code}")
75
  st.text(response.text)
76
  except Exception as e:
77
+ st.error(f" Request failed: {e}")