mdsalmon159 commited on
Commit
cdefe97
·
verified ·
1 Parent(s): 3c181a7

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +4 -12
app.py CHANGED
@@ -1,15 +1,4 @@
1
 
2
- from flask import Flask
3
-
4
- def create_app():
5
- app = Flask(__name__)
6
- # ... any other app configuration
7
- @app.route("/v1/sales_batch", methods=["POST"])
8
- def sales_batch():
9
- return "Sales batch endpoint"
10
- return app
11
-
12
-
13
  import numpy as np
14
  import joblib
15
  import pandas as pd
@@ -20,6 +9,7 @@ superkart_api = Flask("superkart_sales_api")
20
 
21
  # Load the trained model (must be in same folder as app.py)
22
  try:
 
23
  model = joblib.load("superkart_prediction.joblib")
24
  print("✅ Model loaded successfully.")
25
  except Exception as e:
@@ -82,7 +72,8 @@ def predict_sales():
82
  return jsonify({'error': f"Prediction failed: {str(e)}"}), 500
83
 
84
  # BATCH SALES PREDICTION
85
- @app.route("/v1/sales_batch", methods=["POST"])
 
86
  def predict_sales_batch():
87
  try:
88
  file = request.files.get("file")
@@ -103,4 +94,5 @@ def predict_sales_batch():
103
 
104
  # Local testing
105
  if __name__ == '__main__':
 
106
  superkart_api.run(debug=True, host='0.0.0.0', port=7860)
 
1
 
 
 
 
 
 
 
 
 
 
 
 
2
  import numpy as np
3
  import joblib
4
  import pandas as pd
 
9
 
10
  # Load the trained model (must be in same folder as app.py)
11
  try:
12
+ # This assumes 'superkart_prediction.joblib' is in the same directory as app.py
13
  model = joblib.load("superkart_prediction.joblib")
14
  print("✅ Model loaded successfully.")
15
  except Exception as e:
 
72
  return jsonify({'error': f"Prediction failed: {str(e)}"}), 500
73
 
74
  # BATCH SALES PREDICTION
75
+ # Corrected decorator to use the `superkart_api` instance
76
+ @superkart_api.route("/v1/sales_batch", methods=["POST"])
77
  def predict_sales_batch():
78
  try:
79
  file = request.files.get("file")
 
94
 
95
  # Local testing
96
  if __name__ == '__main__':
97
+ # This will still use superkart_api for local runs
98
  superkart_api.run(debug=True, host='0.0.0.0', port=7860)