Skip to content

Commit a5f9182

Browse files
authored
Create app.py
1 parent b569f3b commit a5f9182

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

Fake-News-Detector/app.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import pickle
2+
from flask import Flask, request, render_template
3+
4+
app = Flask(__name__)
5+
model = pickle.load(open('pac.pkl', 'rb'))
6+
tfidf = pickle.load(open('tfidf_vectorizer.pkl','rb'))
7+
8+
@app.route('/')
9+
def home():
10+
return render_template('home.html')
11+
12+
13+
@app.route('/predict',methods=['POST'])
14+
def predict():
15+
if request.method == 'POST':
16+
news = request.form['news']
17+
data = [news]
18+
vect = tfidf.transform(data)
19+
my_prediction = model.predict(vect)
20+
return render_template('prediction.html', prediction=my_prediction)
21+
22+
if __name__ == '__main__':
23+
app.run(debug=True)

0 commit comments

Comments
 (0)