|
from flask import Flask, render_template, request |
|
from retrieve_bot import ChatBot |
|
import nltk |
|
|
|
app = Flask(__name__) |
|
nltk.download("punkt") |
|
chatSheldon = ChatBot() |
|
chatSheldon.load() |
|
|
|
|
|
|
|
|
|
@app.route("/") |
|
def index(): |
|
return render_template("chat.html") |
|
|
|
|
|
@app.route("/get", methods=["GET", "POST"]) |
|
def chat(): |
|
msg = request.form["msg"] |
|
input = msg |
|
return get_Chat_response(input) |
|
|
|
|
|
def get_Chat_response(text): |
|
answer = chatSheldon.generate_response(text) |
|
return answer |
|
|
|
|
|
if __name__ == "__main__": |
|
app.run(debug=True, port=7860) |
|
|