File size: 618 Bytes
096d209
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
270c701
096d209
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from flask import Flask, request, jsonify
from chatbot import chatbot_response

# Initialize Flask app
app = Flask(__name__)

# Route to handle the chat
@app.route("/chat", methods=["POST"])
def chat():
    user_input = request.json.get("message")  # Get user input from POST request
    if not user_input:
        return jsonify({"error": "No message provided"}), 400
    
    # Get chatbot response
    response = chatbot_response(user_input)
    
    return jsonify({"response": response})  # Return the response as a JSON

# Main entry point to run the Flask app
if __name__ == "__main__":
    app.run(debug=True)