• 5.16 个人作业2


    from flask import Flask, jsonify, render_template, request
    
    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()
        print(temp)
        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():
        global temp
        res0 = []
        res1 = []
        res2 = []
        res3 = []
        tiaojian = request.args.get("tiaojian")
        firinput = request.args.get("firinput")
        jingzhun = request.args.get("jingzhun")
        # print(tiaojian)
        # print(firinput)
        # print(jingzhun)
        if jingzhun == '精准':
            if tiaojian == '题目':
                temp = MysqlUtil.select_lunwenj('title', firinput)
            elif tiaojian == '摘要':
                temp = MysqlUtil.select_lunwenj('abstract', firinput)
            elif tiaojian == '作者':
                temp = MysqlUtil.select_lunwenj('zuozhe', firinput)
            elif tiaojian == '关键词':
                temp = MysqlUtil.select_lunwenj('abstract', firinput)
    
        else:
            if tiaojian == '题目':
                temp = MysqlUtil.select_lunwenm('title', firinput)
            elif tiaojian == '摘要':
                temp = MysqlUtil.select_lunwenm('abstract', firinput)
            elif tiaojian == '作者':
                temp = MysqlUtil.select_lunwenm('zuozhe', firinput)
            elif tiaojian == '关键词':
                temp = MysqlUtil.select_lunwenm('abstract', firinput)
        for i in temp:
            res0.append(i[0])  # title
            res1.append(i[1])  # link
            res2.append(i[3])  # zuozhe
            res3.append(i[4])  # time
        qw = jsonify({"title": res0, "zuozhe": res2, "time": res3, "lianjie": res1})
        return jsonify({"title": res0, "zuozhe": res2, "time": res3, "lianjie": res1})
    
    
    
    
    if __name__ == '__main__':
        app.run(debug=True, host='127.0.0.1', port='5000')
  • 相关阅读:
    矩阵相关计算-基础
    列表-元祖-字典
    Python制作NTF传递函数工况文件和后处理文件
    C++栈和堆的生长方向
    malloc/free与new/delete的区别
    C++中4个类型转换相关的关键字/特点/应用场合
    Python 拾遗
    Python 常用库
    Python 视频转字符动画
    Python 命令行(CLI)基础库
  • 原文地址:https://www.cnblogs.com/dty602511/p/14914576.html
Copyright © 2020-2023  润新知