1 Star 0 Fork 1

daniufei/ShowKnowledge

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
app.py 1.89 KB
一键复制 编辑 原始数据 按行查看 历史
XuekaiChen 提交于 2022-05-30 18:16 . 主程序
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()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/daniufei/ShowKnowledge.git
git@gitee.com:daniufei/ShowKnowledge.git
daniufei
ShowKnowledge
ShowKnowledge
main

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385