Spaces:
Running
Running
| from flask import Flask, request, jsonify, render_template | |
| import pickle | |
| app = Flask(__name__) | |
| # Load the pickled pipeline | |
| with open('pipeline.pkl', 'rb') as file: | |
| pipeline = pickle.load(file) | |
| def home(): | |
| return render_template('index.html') | |
| def predict(): | |
| data = request.get_json(force=True) | |
| text = data['text'] | |
| prediction = pipeline.predict([text])[0] | |
| return jsonify({'prediction': prediction}) | |
| if __name__ == '__main__': | |
| app.run(debug=True) | |