jaynopponep's picture
configuring gunicorn timeout length
fdcf510
raw
history blame contribute delete
675 Bytes
from flask import Flask, render_template, request, jsonify
import model
app = Flask(__name__)
# Load data and train the model globally
df = model.load_data('AI_Human.csv') # Make sure this path is correct
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)