-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.py
29 lines (23 loc) · 926 Bytes
/
server.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from flask import Flask, render_template, request, redirect
from chatterbot import ChatBot
from chatterbot.training.trainers import ChatterBotCorpusTrainer
chatbot = ChatBot("Virtual RA", logic_adapters=["chatterbot.adapters.logic.ClosestMatchAdapter", "chatterbot.adapters.logic.TimeLogicAdapter", "chatterbot.adapters.logic.MathematicalEvaluation"])
chatbot.set_trainer(ChatterBotCorpusTrainer)
chatbot.train("chatterbot.corpus.english")
app = Flask(__name__)
query = "question goes here"
reply = "bot reply goes here!"
@app.route('/')
def hello_world():
return render_template('index.html', questionAsked=query, response=reply)
@app.route('/signup', methods = ['POST'])
def signup():
global query
global reply
query = request.form['question']
response = chatbot.get_response(query)
print(response)
reply = response
return redirect('/')
if __name__ == "__main__":
app.run()