-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathapp.py
53 lines (41 loc) · 1.5 KB
/
app.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
42
43
44
45
46
47
48
49
50
51
52
53
from flask import Flask, render_template, request, jsonify
from flask_caching import Cache
from datetime import timedelta
from neo_db.query_graph import query, get_KGQA_answer, get_answer_profile
from KGQA.ltp import get_target_array
app = Flask(__name__)
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = timedelta(seconds=1)
# cache = Cache(app, config={'CACHE_TYPE': 'simple'})
# cache.init_app(app)
@app.route('/', methods=['GET', 'POST'])
@app.route('/index', methods=['GET', 'POST'])
def index(name=None):
return render_template('index.html', name = name)
@app.route('/search', methods=['GET', 'POST'])
def search():
return render_template('search.html')
@app.route('/KGQA', methods=['GET', 'POST'])
def KGQA():
return render_template('KGQA.html')
@app.route('/get_profile',methods=['GET','POST'])
def get_profile():
name = request.args.get('character_name')
json_data = get_answer_profile(name)
return jsonify(json_data)
@app.route('/KGQA_answer', methods=['GET', 'POST'])
def KGQA_answer():
question = request.args.get('name')
json_data = get_KGQA_answer(get_target_array(str(question)))
return jsonify(json_data)
@app.route('/search_name', methods=['GET', 'POST'])
def search_name():
name = request.args.get('name')
json_data=query(str(name))
return jsonify(json_data)
@app.route('/get_all_relation', methods=['GET', 'POST'])
# @cache.cached(5)
def get_all_relation():
return render_template('all_relation.html')
if __name__ == '__main__':
app.debug=True
app.run()