接受表单(form)请求后
if request.method=="POST":
sents = request.form["sents"]
summary_sents = summary(sents)
data= {"summary_sents":summary_sents}
return json.dumps({
"data":data,
"status":1,
"message":"success",
"code":200,
"success":True,
})
返回不是真正的json
{"data": {"summary_sents": "Doug melton's lab is working to eliminate the practice of regular blood checks. Replacing them with insulin-producing cells that measure glucose levels and secrete just right amount, specifically pancreatic beta cell transplantation (ipct) they have developed methods for making hundred"}, "status": 1, "message": "success", "code": 200, "success": true}
改为Response(json.dumps(字典),content_type=“application/json”)
from flask import (
Blueprint, flash, g, redirect, render_template, request, session, url_for,jsonify, Response
)
if request.method=="POST":
sents = request.form["sents"]
summary_sents = summary(sents)
data= {"summary_sents":summary_sents}
return Response(json.dumps({
"data":data,
"status":1,
"message":"success",
"code":200,
"success":True,
}),content_type="application/json")
才是真正的json
{
"data": {
"summary_sents": "Doug melton's lab is working to eliminate the practice of regular blood checks. Replacing them with insulin-producing cells that measure glucose levels and secrete just right amount, specifically pancreatic beta cell transplantation (ipct) they have developed methods for making hundred"
},
"status": 1,
"message": "success",
"code": 200,
"success": true
}