-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
32 lines (25 loc) · 866 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
from flask import Flask, request, jsonify, render_template
from chatbot import get_chatbot_response, handle_user_query
app = Flask(__name__)
@app.route('/')
def home():
return render_template('index.html')
@app.route('/chat', methods=['POST'])
def chat():
data = request.json
question = data.get('question', '')
if not question:
return jsonify({'error': 'No question provided'}), 400
response = get_chatbot_response(question)
return jsonify(response)
@app.route('/chatbot', methods=['POST'])
def chatbot_response():
try:
data = request.get_json()
user_query = data.get('query')
response = handle_user_query(user_query)
return jsonify({'response': response})
except Exception as e:
return jsonify({'error': str(e)}), 500
if __name__ == '__main__':
app.run(debug=True)