Chatbot2 / app.py
jithenderchoudary's picture
Update app.py
096d209 verified
raw
history blame contribute delete
618 Bytes
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)