Spaces:
Sleeping
Sleeping
Download app.py from mohith96/SuperKartBackend: direct link, hf CLI and curl.
- Browser
- Download file 788 Bytes
-
https://huggingface.co/spaces/mohith96/SuperKartBackend/resolve/main/app.py
- Command line
-
hf download hf://spaces/mohith96/SuperKartBackend/app.py
-
curl -L -o app.py https://huggingface.co/spaces/mohith96/SuperKartBackend/resolve/main/app.py
788 Bytes
| from flask import Flask, request, jsonify | |
| import pandas as pd | |
| import joblib | |
| # Load the trained SuperKart model | |
| sales_model = joblib.load("random_forest_pipeline.pkl") | |
| # Initialize Flask application | |
| app = Flask(__name__) | |
| # Root endpoint | |
| def index(): | |
| return "SuperKart Sales Prediction Project" | |
| # Prediction endpoint | |
| def make_prediction(): | |
| try: | |
| input_data = request.get_json() | |
| input_df = pd.DataFrame([input_data]) | |
| forecast = sales_model.predict(input_df)[0] | |
| return jsonify({'Predicted_Sales_Product': round(forecast, 2)}) | |
| except Exception as err: | |
| return jsonify({'error': str(err)}) | |
| # Launch the Flask server | |
| if __name__ == '__main__': | |
| app.run(host='0.0.0.0', port=7860) | |