Untitled
plain_text
15 days ago
653 B
2
Indexable
Never
from flask import Flask, render_template, request from chatterbot import ChatBot from chatterbot.trainers import ChatterBotCorpusTrainer app = Flask(__name__) # Create a chatbot instance chatbot = ChatBot('MyChatBot') # Train the chatbot using the English corpus trainer = ChatterBotCorpusTrainer(chatbot) trainer.train('chatterbot.corpus.english') @app.route("/") def home(): return render_template("index.html") @app.route("/get_response", methods=['POST']) def get_response(): user_message = request.form['user_message'] response = chatbot.get_response(user_message) return str(response) if __name__ == "__main__": app.run()