-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
39 lines (29 loc) · 979 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
37
38
39
from flask import Flask, render_template, request, redirect, url_for
from joblib import load
import pandas as pd
from get_tweets import get_all_tweets
model = load("BERT_CNN.joblib")
def requestResults(name):
tweets = get_all_tweets(name)
tweets['prediction'] = model.predict(tweets['tweet_text'])
pd.set_option('display.max_columns', 50)
pd.set_option('display.max_rows', 50)
pd.options.display.max_colwidth = 20
return str(tweets)
app = Flask(__name__)
@app.route('/')
def home():
return render_template('home.html')
@app.route('/about')
def about():
return render_template('about.html')
@app.route('/', methods=['POST', 'GET'])
def get_data():
if request.method == 'POST':
search = request.form['search']
return redirect(url_for('success', name=search))
@app.route('/success/<name>')
def success(name):
return "<xmp>" + str(requestResults(name)) + " </xmp> "
if __name__ == '__main__' :
app.run(debug=True)