-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
51 lines (42 loc) · 1.59 KB
/
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from flask import Flask, request, render_template, jsonify
app = Flask(__name__, template_folder='public/', static_folder='public/')
from flask_cors import CORS
CORS(app, support_credentials=True)
import qScript
import fScript
import convo_logs
import json
@app.route('/')
def botHome():
return "Finally Works.."
@app.route('/mspcbot')
def mspcBot():
return render_template('index.html')
@app.route('/botservice/question', methods=['POST'])
def retResponseToQuestion():
req = json.loads(request.data)
res = jsonify({'reply': qScript.ping_kb(
req['data']['question'],
req['data']['host'],
req['data']['POSTkey'],
req['data']['key']
)})
print(res)
return res
# -----------------------potential feedback service--------------------------------------------------------------
# @app.route('/botservice/feedback', methods=['POST'])
# def retResponseToFeedback():
# req = json.loads(request.data)
# f = req['data']['feedback']['value']
# res = json.dumps({'reply': fScript.aptResponse(f)})
# return res
# logging for potential feedback service
# @app.route('/botadmin/logs/feedback', methods=['POST'])
# def saveFeedback():
# return 'feedback logged' if convo_logs.storeNewFeedbackLog(request.data) else 'feedback not logged'
# ---------------------------------------------------------------------------------------------------------------
@app.route('/botadmin/logs/chat', methods=['POST'])
def saveChatLogs():
return 'chat logged' if convo_logs.storeNewChat(request.data) else 'chat not logged'
if __name__ == '__main__':
app.run()