-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
79 lines (63 loc) · 2.34 KB
/
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
from flask import *
import pickle
import datetime as dt
import get_tweets_update
import twitter_key
import tweepy
monthData = pickle.load( open( "dashboardData/monthData.pkl", "rb" ) )
dayData = pickle.load( open( "dashboardData/dayData.pkl", "rb" ) )
mostActiveAccounts = pickle.load( open( "dashboardData/mostActiveAccounts.pkl", "rb" ) )
mostFollowedAccounts = pickle.load( open( "dashboardData/mostFollowedAccounts.pkl", "rb" ) )
mostViralAccounts = pickle.load( open( "dashboardData/mostViralAccounts.pkl", "rb" ) )
negativeReasons = pickle.load( open( "dashboardData/neg_reasons.pkl", "rb" ) )
china_sentiments = pickle.load( open( "dashboardData/china_sentiments.pkl", "rb" ) )
world_sentiments = pickle.load( open( "dashboardData/country_senti_dict_cumm.pkl", "rb" ) )
india_data={
'monthData':monthData,
'dayData': dayData,
'mostActiveAccounts':mostActiveAccounts,
'mostFollowedAccounts':mostFollowedAccounts,
'mostViralAccounts':mostViralAccounts,
'negativeReasons':negativeReasons
}
world_data={
'china' : china_sentiments,
'world_sentiments' : world_sentiments
}
auth = tweepy.OAuthHandler(twitter_key.consumer_key,twitter_key.consumer_secret)
auth.set_access_token(twitter_key.access_token, twitter_key.access_token_secret)
api = tweepy.API(auth,wait_on_rate_limit=True)
app= Flask(__name__)
@app.route('/india')
def india():
return render_template('india.html')
@app.route('/indiaData')
def indiaData():
# print('get request')
return india_data
@app.route('/world')
def world():
return render_template('world.html')
@app.route('/worldData')
def worldData():
return world_data
@app.route('/liveMeter')
def getLiveMeter():
return render_template('liveMeter.html')
@app.route('/liveData')
def getLiveData():
tweets = tweepy.Cursor(api.search,q="#covid" + " -filter:retweets",rpp=5,lang="en", tweet_mode='extended').items(10)
dat = get_tweets_update.driver(tweets)
print(dat)
return {'data':dat}
@app.route('/liveTweetData')
def getLiveTweet():
tweets = tweepy.Cursor(api.search,q="#covid" + " -filter:retweets",rpp=5,lang="en", tweet_mode='extended').items(1)
dat = get_tweets_update.driver(tweets)
print(dat)
return {'data':dat}
@app.route('/home')
def getHome():
return render_template('home.html')
if __name__ == '__main__':
app.run(threaded = True, debug=True)