-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
46 lines (38 loc) · 1.19 KB
/
test.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
from flask import Flask, url_for, request, render_template, Markup, redirect
import twitter_wrapper
import sentiment_analysis
app = Flask(__name__)
@app.route('/')
def hello_world():
return redirect('home')
@app.route('/home')
def show_user_profile(username=None):
return render_template('Home.html', username=username)
@app.route('/home/<username>', methods=['GET', 'POST'])
def login(username):
if request.method == 'GET':
return ' ||| '.join(twitter_wrapper.getUserTweets(username))
else:
return hello()
@app.route('/analysis/<username>', methods=['GET'])
def ana(username):
if request.method == 'GET':
ret = ""
data = sentiment_analysis.find_negative_tweets(username)[0]
ret = " ".join(data) + "|||"
users = twitter_wrapper.getUserFollowers(username)
bad_tweets = []
for i in users:
bet = sentiment_analysis.find_negative_tweets(i)[0]
if(len(bet) >= 1):
bad_tweets.append(' '.join(bet))
ret = ret + ' '.join(bad_tweets)
return ret
else:
return hello()
'''with app.test_request_context():
print url_for('hello_world')
print url_for('projects')
print url_for('about', next='/')
print url_for('hello', username='SyedA')
print url_for('static', filename='home.css') '''