|
|
from flask import Flask, request, jsonify
|
|
|
import pickle
|
|
|
import numpy as np
|
|
|
|
|
|
app = Flask(__name__)
|
|
|
|
|
|
|
|
|
with open("xgb_superkart_model.pkl", "rb") as f:
|
|
|
model = pickle.load(f)
|
|
|
|
|
|
@app.route("/")
|
|
|
def home():
|
|
|
return "SuperKart Sales Forecast API is Live"
|
|
|
|
|
|
@app.route("/predict", methods=["POST"])
|
|
|
def predict():
|
|
|
data = request.get_json(force=True)
|
|
|
input_features = np.array(data["features"]).reshape(1, -1)
|
|
|
prediction = model.predict(input_features)
|
|
|
return jsonify({"predicted_sales": prediction[0]})
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
app.run(host='0.0.0.0', port=7860)
|
|
|
|