-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__init__.py
executable file
·85 lines (67 loc) · 2.36 KB
/
__init__.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
80
81
82
83
84
85
import boto3
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello, World!'
# config
@app.route('/config/')
@app.route('/config/<file>')
def show_config(file='feeds.json'):
filename = 'rob_princetonventures'
filename = filename + '/feeds.json'
# get the preprocessed file from s3
s3 = boto3.resource('s3')
object = s3.Object('com.frontanalytics.feedreader',filename)
result = object.get()["Body"].read()
return result
# for the current day's worth of tweets to read
# call feed/filtered_health/besthealth
@app.route('/feed/<feedcategory>/<feedname>/')
def show_xml(feedcategory, feedname, source='cleaned', daysago='0'):
filename = 'rob_princetonventures'
if ( feedcategory!='' ):
filename = filename+'/%s' % feedcategory
if ( feedname!='' ):
filename = filename+'/%s' % feedname
filename = filename + '/cleaned_latest.xml'
# get the preprocessed file from s3
s3 = boto3.resource('s3')
object = s3.Object('com.frontanalytics.feedreader',filename)
result = object.get()["Body"].read()
return result
# return the log
@app.route('/log/')
@app.route('/log/<feedcategory>/')
@app.route('/log/<feedcategory>/<feedname>/')
def show_log(feedcategory, feedname, source='cleaned', daysago='0'):
filename = 'rob_princetonventures'
if ( feedcategory!='' ):
filename = filename+'/%s' % feedcategory
if ( feedname!='' ):
filename = filename+'/%s' % feedname
filename = filename + '/log.html'
# get the preprocessed file from s3
s3 = boto3.resource('s3')
object = s3.Object('com.frontanalytics.feedreader',filename)
result = object.get()["Body"].read()
return result
# for all the word counts
@app.route('/entities/')
@app.route('/entities/<feedcategory>/')
@app.route('/entities/<feedcategory>/<feedname>/')
def show_entities(feedcategory='', feedname=''):
# create the filename
filename = 'rob_princetonventures'
if ( feedcategory!='' ):
filename = filename+'/%s' % feedcategory
if ( feedname!='' ):
filename = filename+'/%s' % feedname
filename = filename + '/entities.csv'
# get the preprocessed file from s3
s3 = boto3.resource('s3')
object = s3.Object('com.frontanalytics.feedreader',filename)
result = object.get()["Body"].read()
return result
if __name__ == "__main__":
app.run()