Download app.py from omm7/w4backend: direct link, hf CLI and curl.
- Browser
- Download file 675 Bytes
-
https://huggingface.co/spaces/omm7/w4backend/resolve/main/app.py
- Command line
-
hf download hf://spaces/omm7/w4backend/app.py
-
curl -L -o app.py https://huggingface.co/spaces/omm7/w4backend/resolve/main/app.py
675 Bytes
| from flask import Flask, request, jsonify | |
| import numpy as np | |
| import xgboost as xgb | |
| app = Flask(__name__) | |
| # Load model from JSON (instead of pickle) | |
| model = xgb.Booster() | |
| model.load_model("xgb_superkart_model.json") | |
| def root(): | |
| return "SuperKart Sales Forecasting API is running." | |
| def predict(): | |
| data = request.get_json(force=True) | |
| features = np.array(data["features"]).reshape(1, -1) | |
| dmatrix = xgb.DMatrix(features) | |
| prediction = model.predict(dmatrix) | |
| return jsonify({"prediction": float(prediction[0])}) | |
| if __name__ == "__main__": | |
| app.run(host="0.0.0.0", port=7860) | |