Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -39,17 +39,24 @@ if submitted:
|
|
| 39 |
"Store_Type": store_type
|
| 40 |
}]
|
| 41 |
|
| 42 |
-
# Send request to your Flask API
|
| 43 |
try:
|
| 44 |
response = requests.post(
|
| 45 |
"https://Mahendra87-IP-SuperMart.hf.space/predict",
|
| 46 |
-
json=input_payload
|
|
|
|
| 47 |
)
|
|
|
|
| 48 |
if response.status_code == 200:
|
| 49 |
result = response.json()
|
| 50 |
-
|
| 51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
else:
|
| 53 |
-
st.error("Prediction failed.
|
|
|
|
| 54 |
except Exception as e:
|
| 55 |
st.error(f"API request failed: {e}")
|
|
|
|
| 39 |
"Store_Type": store_type
|
| 40 |
}]
|
| 41 |
|
|
|
|
| 42 |
try:
|
| 43 |
response = requests.post(
|
| 44 |
"https://Mahendra87-IP-SuperMart.hf.space/predict",
|
| 45 |
+
json=input_payload,
|
| 46 |
+
timeout=10
|
| 47 |
)
|
| 48 |
+
|
| 49 |
if response.status_code == 200:
|
| 50 |
result = response.json()
|
| 51 |
+
st.write("API response:", result) # Helpful for debugging
|
| 52 |
+
|
| 53 |
+
if "prediction" in result:
|
| 54 |
+
prediction = result["prediction"][0]
|
| 55 |
+
st.success(f"Predicted Product Sales: ₹{round(prediction, 2)}")
|
| 56 |
+
else:
|
| 57 |
+
st.error("'prediction' key not found in API response.")
|
| 58 |
else:
|
| 59 |
+
st.error(f"Prediction failed. Status code: {response.status_code}")
|
| 60 |
+
st.text(response.text)
|
| 61 |
except Exception as e:
|
| 62 |
st.error(f"API request failed: {e}")
|