-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
31 lines (20 loc) · 796 Bytes
/
app.py
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
27
28
29
30
31
from flask import Flask, escape, request, render_template
import pickle
vector = pickle.load(open("TFID_Vectorizer.pkl", 'rb'))
model = pickle.load(open("output_model.pkl", 'rb'))
app = Flask(__name__, static_url_path='/static')
@app.route('/')
def hello_world():
return render_template("index.html")
@app.route('/prediction', methods=['GET', 'POST'])
def prediction():
if request.method == "POST":
news = str(request.form['news'])
print(news)
predict = model.predict(vector.transform([news]))[0]
print(predict)
return render_template("prediction.html", prediction_text="Verification Result: {}".format(predict.capitalize()))
else:
return render_template("prediction.html")
if __name__ == '__main__':
app.run(debug=True)