-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapp.py
More file actions
38 lines (25 loc) · 789 Bytes
/
app.py
File metadata and controls
38 lines (25 loc) · 789 Bytes
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
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
'''
@File : app.py
@Author : Racle
@Version : 1.0
@Desc : None
'''
from dialogue import DialogManager
from flask import Flask, render_template, request
app = Flask(__name__, static_folder='templates', static_url_path='')
# 因为在使用sklearn tf-idf模型使用时自定义了分词方法, pickle load时需要该方法在__main__空间中
def split_func(s): return s.split()
bot = DialogManager()
@app.route('/api/chat', methods=['GET'])
def chat():
query = request.args.get('message')
print(query)
output = bot.get_answer(query)
return output
@app.route('/')
def main():
return render_template('index.html')
if __name__ == '__main__':
app.run(host='0.0.0.0', port=8000, debug=False)