From 660edac9c925a7ef68e8136d22f65d14ab03b1d5 Mon Sep 17 00:00:00 2001 From: Walker Waylon Scott Date: Mon, 17 Jul 2017 22:28:09 -0500 Subject: [PATCH] added exploritory route and sentiment api --- src/pyDataVizDay.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/pyDataVizDay.py b/src/pyDataVizDay.py index 25fe267..2eede0c 100644 --- a/src/pyDataVizDay.py +++ b/src/pyDataVizDay.py @@ -15,6 +15,8 @@ from flask import Flask from flask import request, render_template, make_response, jsonify, Blueprint, url_for from flask_restplus import Resource, Api, fields, reqparse from flask_cors import CORS, cross_origin +from textblob import TextBlob + import settings import etl import palettes as pal @@ -95,6 +97,11 @@ def enthusiast(): form = render_template('data_form.html', dropdowns=dropdowns, inputs=inputs) 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') def slides(): @@ -197,6 +204,21 @@ class download(Resource): df = data.movie 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__': app.jinja_env.auto_reload = True