Spaces:
Sleeping
Sleeping
Download app.py from Lokiiparihar/Backend: direct link, hf CLI and curl.
- Browser
- Download file 1.11 kB
-
https://huggingface.co/spaces/Lokiiparihar/Backend/resolve/main/app.py
- Command line
-
hf download hf://spaces/Lokiiparihar/Backend/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Lokiiparihar/Backend/resolve/main/app.py
1.11 kB
| import joblib | |
| import pandas as pd | |
| from flask import Flask, request, jsonify | |
| app = Flask("SuperKart Sales Predictor") | |
| model = joblib.load("superkart_model_v1_0.joblib") | |
| def home(): | |
| return "Welcome to the SuperKart Sales Prediction API" | |
| def predict_sales(): | |
| sales_data = request.get_json() | |
| sample = { | |
| "Product_Weight": sales_data['Product_Weight'], | |
| "Product_Sugar_Content": sales_data['Product_Sugar_Content'], | |
| "Product_Allocated_Area": sales_data['Product_Allocated_Area'], | |
| "Product_Type": sales_data['Product_Type'], | |
| "Product_MRP": sales_data['Product_MRP'], | |
| "Store_Establishment_Year": sales_data['Store_Establishment_Year'], | |
| "Store_Size": sales_data['Store_Size'], | |
| "Store_Location_City_Type": sales_data['Store_Location_City_Type'], | |
| "Store_Type": sales_data['Store_Type'] | |
| } | |
| input_data = pd.DataFrame([sample]) | |
| prediction = model.predict(input_data).tolist()[0] | |
| return jsonify({"Predicted Sales": prediction}) | |
| if __name__ == '__main__': | |
| app.run(debug=True) | |