jaynopponep's picture
Deploying new flask, new sklearn based modeling
d96116f
raw
history blame
652 Bytes
from flask import Flask, render_template, request, jsonify
import model # Import your model module
app = Flask(__name__)
# Load data and train the model globally
df = model.load_data()
X_train, X_test, y_train, y_test = model.split_data(df)
pipeline = model.create_pipeline(X_train, y_train)
@app.route('/', methods=['GET', 'POST'])
def home():
if request.method == 'POST':
data = request.json
user_input = data['text']
prediction = model.predict_text(user_input, pipeline)
return jsonify({'classification': prediction})
return render_template('home.html')
if __name__ == '__main__':
app.run(debug=True)