Spaces:
Running
Running
Update app/routes.py
Browse files- app/routes.py +24 -22
app/routes.py
CHANGED
@@ -1,22 +1,24 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
from
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
|
|
|
|
|
1 |
+
# app/routes.py
|
2 |
+
|
3 |
+
from flask import Blueprint, render_template, request, jsonify
|
4 |
+
from app.bot import JupiterFAQBot
|
5 |
+
|
6 |
+
main = Blueprint('main', __name__)
|
7 |
+
bot = JupiterFAQBot()
|
8 |
+
|
9 |
+
@main.route('/')
|
10 |
+
def index():
|
11 |
+
return render_template('index.html')
|
12 |
+
|
13 |
+
@main.route('/chat', methods=['POST'])
|
14 |
+
def chat():
|
15 |
+
data = request.json
|
16 |
+
question = data.get('question', '')
|
17 |
+
|
18 |
+
response = bot.generate_response(question)
|
19 |
+
suggestions = bot.suggest_related_queries(question)
|
20 |
+
|
21 |
+
return jsonify({
|
22 |
+
'response': response,
|
23 |
+
'suggestions': suggestions
|
24 |
+
})
|