-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
34 lines (27 loc) · 872 Bytes
/
app.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
from flask import Flask
from flask import request
from flask import jsonify
from flask_cors import CORS
from feedback.cohere import *
from emails.send_email import *
app = Flask(__name__)
cors = CORS(app)
@app.route("/")
def hello_world():
return "<p>Hello, World!</p>"
# assumes text input
@app.get("/feedback")
def feedback():
answer = request.args.get("answer")
sentiment = classify_sentiment(answer)
word_choice = classify_word_choice(answer)
clarity = classify_clarity(answer)
response = jsonify({"sentiment": sentiment, "word_choice": word_choice, "clarity": clarity})
return response
@app.post("/email")
def email():
# data is {email: [email protected], feedback: [{question, response, word_choice, clarity, tone, timing}]}
data = request.get_json()
print(data)
send_email(data)
return jsonify({"status": 200})