File size: 708 Bytes
4cd6925
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22d28e4
4cd6925
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from flask import Flask, request, jsonify
import dynamic_pricing 
import joblib

app = Flask(__name__)

loaded_rf_model = joblib.load("random_forest_model.pkl")

@app.route('/', methods=['POST'])
def predict_amt():
    try:
        # Get data from the request
        data = request.get_json()

        # Use your machine learning model to make predictions
        prediction = loaded_rf_model.predict(data)  # Replace with your model code
    
        # Return the prediction as a JSON response
        return jsonify({'prediction': prediction})
    
    except Exception as e:
        return jsonify({'error': str(e)}), 400


if __name__ == "__main__":
     app.run(host="0.0.0.0", port=5000, debug=True)