added exploritory route and sentiment api

This commit is contained in:
Walker Waylon Scott 2017-07-17 22:28:09 -05:00
parent 677066e48a
commit 660edac9c9

View file

@ -15,6 +15,8 @@ from flask import Flask
from flask import request, render_template, make_response, jsonify, Blueprint, url_for from flask import request, render_template, make_response, jsonify, Blueprint, url_for
from flask_restplus import Resource, Api, fields, reqparse from flask_restplus import Resource, Api, fields, reqparse
from flask_cors import CORS, cross_origin from flask_cors import CORS, cross_origin
from textblob import TextBlob
import settings import settings
import etl import etl
import palettes as pal import palettes as pal
@ -95,6 +97,11 @@ def enthusiast():
form = render_template('data_form.html', dropdowns=dropdowns, inputs=inputs) form = render_template('data_form.html', dropdowns=dropdowns, inputs=inputs)
return render_template('enthusiast.html', form=form) return render_template('enthusiast.html', form=form)
@app.route('/Exploritory')
def exploritory():
notebook = render_template('Exploritory_nb.html')
return render_template('Exploritory.html', body=notebook)
@app.route('/slides') @app.route('/slides')
def slides(): def slides():
@ -197,6 +204,21 @@ class download(Resource):
df = data.movie df = data.movie
return return_csv(df, 'movie.csv') return return_csv(df, 'movie.csv')
@api.route('/sentiment')
@api.expect(parser)
class sentiment(Resource):
def get(self):
args = parser.parse_args()
data = filter_with_args(args)
keywords = TextBlob(' '.join(data.keyword.plot_keywords.values))
results = {'columns':[['polarity'] + [round(keywords.sentiment.polarity + .1, 3) * 250],
['subjectivity'] + [round(keywords.sentiment.subjectivity + .1, 3) * 150]],
'colors':{'polarity':'grey',
'subjectivity':'#afafaf'}
}
return jsonify(results)
if __name__ == '__main__': if __name__ == '__main__':
app.jinja_env.auto_reload = True app.jinja_env.auto_reload = True