代码拉取完成,页面将自动刷新
同步操作将从 zengyuhang1994/ShowKnowledge 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
from flask import Flask, render_template, request, jsonify, json
from neo_db.query_graph import query, get_details, get_all_graph
from neo_db.robot_answer import get_robot_answer
app = Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
@app.route('/index', methods=['GET', 'POST'])
def index(name=None):
return render_template('index.html', name=name)
@app.route('/query_node', methods=['GET', 'POST'])
def search_page():
return render_template('query_node.html')
@app.route('/get_all_relation', methods=['GET', 'POST'])
def get_all_relation():
return render_template('all_relation.html')
@app.route('/dialogue', methods=['GET', 'POST'])
def dialogue_page():
# 需要返回json数据格式嵌入HTML
return render_template('dialogue.html')
@app.route('/get_profile',methods=['GET','POST'])
def get_profile():
choice = request.args.get('choice')
limit = request.args.get('limit')
json_data = get_all_graph(choice, limit)
return jsonify(json_data)
@app.route('/search_node', methods=['GET', 'POST'])
def search_node():
choice = request.args.get('choice')
name = request.args.get('name')
json_data = query(choice, str(name))
return jsonify(json_data)
@app.route('/get_chart', methods=['GET', 'POST'])
def get_chart():
node_or_edge = json.loads(request.form.get('type')) # $.ajax传多个参数只能post请求,对应form
data = json.loads(request.form.get('data'))
nodes = json.loads(request.form.get('nodes'))
json_data = get_details(node_or_edge, data, nodes)
return jsonify(json_data)
@app.route('/dialogue_answer', methods=['GET', 'POST'])
def dialogue_answer():
question = request.args.get('name')
robot_answer = get_robot_answer(str(question).strip())
json_data = {'data': robot_answer}
json_data['data'].replace("\n", "<br>")
return jsonify(json_data)
if __name__ == '__main__':
app.debug = True
app.run()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。