forked from mandar196/Fake_News_Classifier_NLP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
26 lines (21 loc) · 652 Bytes
/
app.py
File metadata and controls
26 lines (21 loc) · 652 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
25
26
from flask import Flask, render_template, request, url_for, Markup, jsonify
import pickle
app = Flask(__name__)
pickle_in = open('model_fakenews.pickle','rb')
pac = pickle.load(pickle_in)
tfid = open('tfid.pickle','rb')
tfidf_vectorizer = pickle.load(tfid)
@app.route('/')
def home():
return render_template("index.html")
@app.route('/newscheck')
def newscheck():
abc = request.args.get('news')
input_data = [abc.rstrip()]
# transforming input
tfidf_test = tfidf_vectorizer.transform(input_data)
# predicting the input
y_pred = pac.predict(tfidf_test)
return jsonify(result = y_pred[0])
if __name__=='__main__':
app.run(debug=True)