用postman做接口的时候首先在文件方面
1.myrun.py
import json
from flask import Blueprint
from flask import request
from flask import jsonify
from nlg_yongzhuo import text_rank
xiaohua=Blueprint("xiaohua",__name__)
@xiaohua.route("/mytest",methods=["POST"])
def mytest():
doc_text=request.args.get("doc")
method=request.args.get("method")
sums_textrank = text_rank.summarize(doc_text, num=6, model_type=method)
a=[]
for sum_ in sums_textrank:
a.append(sum_[1])
result = ";".join(a)
return jsonify({"doc":doc_text, "method":method,"result":result})
2.run_server.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 20-3-30 下午2:18
# @Author : wangyanyang
# @Site :
# @File : run_server.py
# @Software: PyCharm
from flask import Flask
from myrun import xiaohua
app=Flask(__name__)
app.register_blueprint(xiaohua,url_prefix="/xiaohua")
if __name__=="__main__":
app.run(host="0.0.0.0",port=10086,debug=True)
3.输入url时:http://127.0.0.1:10086/xiaohua/mytest?key1=""&key2=""
其中端口之后要加入蓝图/函数?