flask文件
from flask import Flask, jsonify, render_template, request, json
import MysqlUtil
app = Flask(__name__)
@app.route("/c1")
def hellv():
return render_template('view.html')
@app.route("/text")
def hellt():
return render_template('text.html')
@app.route("/findlunwen")
def hello():
return
@app.route("/")
def hellp():
return render_template('find.html')
@app.route("/c2", methods=['POST', 'GET'])
def wordcloud():
res0 = []
res1 = []
temp = MysqlUtil.select_key()
for i in temp:
res0.append(i[0]) # keyword
res1.append(i[1]) # value
return jsonify({"keyword": res0, "value": res1})
@app.route("/c3", methods=['POST', 'GET'])
def select_lunwen():
res0 = []
res1 = []
res2 = []
res3 = []
str0 = ""
realsum = request.args.get("realsum")
a = int(realsum)
for i in range(a):
if i == 0:
tiaojian = request.args.get("tiaojian")
firinput = request.args.get("firinput")
jingzhun = request.args.get("jingzhun")
if tiaojian == '题目':
tiaojian = 'title'
elif tiaojian == '摘要':
tiaojian = 'abstract'
elif tiaojian == '作者':
tiaojian = 'zuozhe'
elif tiaojian == '关键词':
tiaojian = 'abstract'
if jingzhun=='模糊':
str0 = tiaojian+" like '%%"+firinput+"%%'"
else:
str0 = tiaojian + " = '" + firinput + "'"
else:
str1 = "tiaojian"+str(i)
str2 = "input"+str(i)
str3 = "jingdu"+str(i)
str4 = "lianjie" + str(i)
tiaojian = request.args.get(str1)
firinput = request.args.get(str2)
jingzhun = request.args.get(str3)
lianjie = request.args.get(str4)
print(tiaojian)
if tiaojian == '题目':
tiaojian = 'title'
elif tiaojian == '摘要':
tiaojian = 'abstract'
elif tiaojian == '作者':
tiaojian = 'zuozhe'
elif tiaojian == '关键词':
tiaojian = 'abstract'
if jingzhun == '模糊':
str0 = str0 +" "+lianjie+" "+tiaojian+" like '%%"+firinput+"%%'"
else:
str0 = str0 +" "+lianjie+" "+tiaojian+" = '"+firinput+"'"
temp = MysqlUtil.select_lunwenm(str0)
for i in temp:
res0.append(i[0]) # title
res1.append(i[1]) # link
res2.append(i[3]) # zuozhe
res3.append(i[4]) # time
return jsonify({"title": res0, "zuozhe": res2, "time": res3, "lianjie": res1})
if __name__ == '__main__':
app.run(debug=True, host='127.0.0.1', port='5000')