from flask import Flask, render_template
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer

app = Flask(__name__)

english_bot = ChatBot("English Bot",
                      storage_adapter="chatterbot.storage.MongoDatabaseAdapter",
                      database='chatterbot-flask',
                      database_uri='mongodb://172.17.0.1:27017'
                      # ,                      read_only=True
                      )

english_bot.set_trainer(ChatterBotCorpusTrainer)
english_bot.train("chatterbot.corpus.english")


@app.route("/")
def home():
    return render_template("index.html")

@app.route("/get/<string:query>")
def get_raw_response(query):
    return str(english_bot.get_response(query))


if __name__ == "__main__":
    app.run("aa01", port=9000, debug=True)