File size: 699 Bytes
06f4ba9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from flask import Flask, request, render_template
import pickle

# Load the model from the pickle file
with open('gs_clf.pickle', 'rb') as f:
    spam_classifier = pickle.load(f)


# Load the spam classifier
app = Flask(__name__)

@app.route('/', methods=['GET', 'POST'])
def classify_message():
    if request.method == 'POST':
        message = request.form['message']
        print(message)
        prediction = spam_classifier.predict([message])
        print(prediction)
        return render_template('index.html', prediction=prediction[0])

    return render_template('index.html', prediction=None)


if __name__ == '__main__':
    app.run(host='0.0.0.0', port=5000)