Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -33,12 +33,17 @@ input_data = {
|
|
| 33 |
|
| 34 |
# Make prediction when the "Predict" button is clicked
|
| 35 |
if st.button("Predict"):
|
| 36 |
-
|
|
|
|
| 37 |
"https://maddykan101-SalesPredictionBackend.hf.space/v1/prediction",
|
| 38 |
json=input_data
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
# Make prediction when the "Predict" button is clicked
|
| 35 |
if st.button("Predict"):
|
| 36 |
+
try:
|
| 37 |
+
response = requests.post(
|
| 38 |
"https://maddykan101-SalesPredictionBackend.hf.space/v1/prediction",
|
| 39 |
json=input_data
|
| 40 |
+
)
|
| 41 |
+
if response.status_code == 200:
|
| 42 |
+
prediction = response.json()['Predicted Sales '] # Adjust key if needed
|
| 43 |
+
st.success(f"Predicted Sales: {prediction}")
|
| 44 |
+
else:
|
| 45 |
+
st.error(f"Prediction failed: {response.status_code}")
|
| 46 |
+
except Exception as e:
|
| 47 |
+
return jsonify({'error': str(e)}), 500
|
| 48 |
+
|
| 49 |
+
|