修改response

This commit is contained in:
zhaojinghao 2022-12-09 18:27:43 +08:00
parent 15aa5a467a
commit b387ce871d
1 changed files with 4 additions and 4 deletions

8
run.py
View File

@ -14,7 +14,7 @@ TEXT = "text"
app = Flask(__name__)
@app.route('/house_price', methods=["POST"])
@app.route('/house_price/', methods=["POST"])
def predict_price():
resp_info = dict()
if request.method == 'POST':
@ -61,7 +61,7 @@ def predict_price():
resp_info["data"] = out.getvalue()
if resp_info["code"] == 200:
resp = make_response(resp_info["data"])
resp.headers["Content-Disposition"] = "attachment; filename*=utf-8''{}".format("house_price.xlsx")
resp.headers["Content-Disposition"] = "attachment; filename=house_price.xlsx"
resp.headers["Content-type"] = "application/x-xlsx"
else:
resp = make_response(json.dumps(resp_info))
@ -69,7 +69,7 @@ def predict_price():
return resp
@app.route('/ocean_wave_height', methods=["POST"])
@app.route('/ocean_wave_height/', methods=["POST"])
def predict_height():
resp_info = dict()
if request.method == 'POST':
@ -146,7 +146,7 @@ def run_ts_predict():
resp_info["data"] = out.getvalue()
if resp_info.get("code") == 200:
resp = make_response(resp_info["data"])
resp.headers["Content-Disposition"] = "attachment; filename*=utf-8''{}".format(file_name)
resp.headers["Content-Disposition"] = f"attachment; filename={file_name}"
resp.headers["Content-type"] = "application/x-xlsx"
else:
resp = make_response(json.dumps(resp_info))