maddykan101 commited on
Commit
988ffd6
·
verified ·
1 Parent(s): 5b26c10

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -7
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
- response = requests.post(
 
37
  "https://maddykan101-SalesPredictionBackend.hf.space/v1/prediction",
38
  json=input_data
39
- )
40
- if response.status_code == 200:
41
- prediction = response.json()['Predicted Sales '] # Adjust key if needed
42
- st.success(f"Predicted Sales: {prediction}")
43
- else:
44
- st.error(f"Prediction failed: {response.status_code}")
 
 
 
 
 
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
+