Last active
October 11, 2016 23:23
-
-
Save remkohdev/898a3dd295ee323bc42302240ce4ede5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.route('/search') | |
def Search(startdate=None, enddate=None, searchterm=None, count=None): | |
startdateStr = request.args.get('startdate') | |
enddateStr = request.args.get('enddate') | |
searchterm = request.args.get('searchterm') | |
count = request.args.get('count') | |
# format the correct start and end formats | |
startdate = myalchemyapi.FormatDate(startdateStr) | |
enddate = myalchemyapi.FormatDate(enddateStr) | |
# GetNews with Sentiment | |
returnfields = 'enriched.url.url%2Cenriched.url.title%2Cenriched.url.publicationDate.date%2Cenriched.url.docSentiment.score' | |
articles = myalchemyapi.GetNews(searchterm=searchterm, returnfields=returnfields, startdate=startdate, enddate=enddate, count=count) | |
# prepare for d3js, calculate the average sentiment per day | |
uniqueSentimentList = myalchemyapi.ParseNews(articles, startdateStr, enddateStr) | |
response = { | |
'news' : uniqueSentimentList, | |
'startdate' : startdateStr, | |
'enddate' : enddateStr, | |
'searchterm' : searchterm | |
} | |
return render_template('report.html', response=response) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment