Download app.py from omm7/w4p2: direct link, hf CLI and curl.
- Browser
- Download file 619 Bytes
-
https://huggingface.co/spaces/omm7/w4p2/resolve/main/app.py
- Command line
-
hf download hf://spaces/omm7/w4p2/app.py
-
curl -L -o app.py https://huggingface.co/spaces/omm7/w4p2/resolve/main/app.py
619 Bytes
| from flask import Flask, request, jsonify | |
| import pickle | |
| import numpy as np | |
| app = Flask(__name__) | |
| # Load model | |
| with open("xgb_superkart_model.pkl", "rb") as f: | |
| model = pickle.load(f) | |
| def home(): | |
| return "SuperKart Sales Forecast API is Live" | |
| 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) | |