forked from orvice/ChatterBot-flask
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
41 lines (35 loc) · 870 Bytes
/
main.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
30
31
32
33
34
35
36
37
38
39
40
41
from flask import Flask
from flask import json, request
import bot
import config
app = Flask(__name__)
@app.route("/", methods=['GET', 'POST'])
def ask():
msg = request.form['msg']
resp = bot.talk(msg)
print(resp)
data = {
'resp': "%s" % resp
}
response = app.response_class(
response=json.dumps(data),
status=200,
mimetype='application/json'
)
return response
@app.route("/train", methods=['GET', 'POST'])
def hello():
input = request.form['input']
res = request.form['res']
resp = bot.train(input,res)
data = {
'resp': "%s" % resp
}
response = app.response_class(
response=json.dumps(data),
status=200,
mimetype='application/json'
)
return response
if __name__ == "__main__":
app.run(host='0.0.0.0', debug=True, port=config.port)