-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
66 lines (57 loc) · 2.11 KB
/
main.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
from flask import *
import twitterdata
import instagramdata
import engine
import instaloader
app = Flask(__name__)
loader = instaloader.Instaloader()
@app.route('/')
def graph():
return render_template('home.html', title='Home')
@app.route('/tw_graph', methods=['GET', 'POST'])
def tw_graph():
if request.method == 'POST':
username = str(request.form['username-tw'])
all_tweets = twitterdata.get_all_tweets(username)
tweets_output = engine.getOutput(all_tweets)
print("Getting drug vals...")
drug_vals = engine.checkDrugs(tweets_output)
print("Getting weapon vals...")
weapon_vals = engine.checkWeapons(tweets_output)
print("Getting alcohol vals...")
alcohol_vals = engine.checkAlcohol(tweets_output)
x_vals = engine.gen_list(int(len(all_tweets)) + 1)
return render_template(
'tw_graph.html',
name = username,
drug_vals = drug_vals,
weapon_vals = weapon_vals,
alcohol_vals = alcohol_vals,
x_vals = x_vals
)
@app.route('/ig_graph', methods=['GET', 'POST'])
def ig_graph():
if request.method == 'POST':
username = str(request.form['username-ig'])
profile = instaloader.Profile.from_username(loader.context, username)
print(str(profile.userid))
all_posts = instagramdata.get_all_igposts(str(profile.userid))
all_output = engine.getOutput(all_posts)
print(all_posts)
print("Getting drug vals...")
drug_vals = engine.checkDrugs(all_output)
print("Getting weapon vals...")
weapon_vals = engine.checkWeapons(all_output)
print("Getting alcohol vals...")
alcohol_vals = engine.checkAlcohol(all_output)
x_vals = engine.gen_list(int(len(all_posts)) + 1)
return render_template(
'ig_graph.html',
name = username,
drug_vals = drug_vals,
weapon_vals = weapon_vals,
alcohol_vals = alcohol_vals,
x_vals = x_vals,
)
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0',port=8080)