-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
24 lines (18 loc) · 669 Bytes
/
app.py
File metadata and controls
24 lines (18 loc) · 669 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from flask import Flask, render_template, request
import joblib
# Load the saved model and vectorizer
model = joblib.load('spam_classifier_model.pkl')
vectorizer = joblib.load('vectorizer.pkl')
app = Flask(__name__)
@app.route('/')
def home():
return render_template('index.html')
@app.route('/predict', methods=['POST'])
def predict():
email_text = request.form['email_text']
features = vectorizer.transform([email_text])
prediction = model.predict(features)[0]
result = "Spam" if prediction == 1 else "Not Spam"
return render_template('index.html', result=result, email_text=email_text)
if __name__ == "__main__":
app.run(debug=True)