-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
36 lines (25 loc) · 899 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
32
33
34
35
36
#Implement all this concept by machine learning with flask
from flask import Flask, escape, request, render_template
import pickle
vector = pickle.load(open("vectorizer.pkl", 'rb'))
model = pickle.load(open("finalized_model.pkl", 'rb'))
app = Flask(__name__)
@app.route('/')
def home():
return render_template("index.html")
@app.route('/headlines')
def headlines():
return render_template("login.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="News headline is -> {}".format(predict))
else:
return render_template("prediction.html")
if __name__ == '__main__':
app.debug = True
app.run()