-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
39 lines (33 loc) · 1.01 KB
/
app.py
File metadata and controls
39 lines (33 loc) · 1.01 KB
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
from flask import Flask, render_template, request, redirect, jsonify
app = Flask(__name__)
from perspective import perspectiveAPI, spacyFunctions, emotions # our nlp analyses
"""
purpose: Render our website pages.
"""
@app.route('/')
def home():
return render_template('index.html', initScreen = True, sentimentValues={}, emotionsValues = {}, perspectiveValues={})
@app.route('/test')
def test():
return render_template('test.html')
"""
purpose: Take input from the JavaScript form.
"""
@app.route('/analysis', methods = ['POST'])
def analysis():
text = request.form['text']
perspectiveValues = perspectiveAPI(text)
emotionsValues = emotions(text)
sentimentValues = spacyFunctions(text)
# return redirect('/')
return render_template('index.html', text = text,
initScreen = False,
sentimentValues = sentimentValues,
emotionsValues = emotionsValues,
perspectiveValues = perspectiveValues
)
"""
purpose: Run server.
"""
if __name__ == '__main__':
app.run()