【发布时间】:2020-10-05 11:41:40
【问题描述】:
我是编码的初学者,但我被困在最后的结束:| 我正在使用 python 2.7 这是我的 server.py
from flask import Flask, render_template,request,jsonify
import requests
import json
import new
app = Flask(__name__)
#serve homepage
@app.route('/', methods=["GET","POST"])
def homepage():
return render_template('page2.html')
@app.route('/page3.html', methods=["POST"])
def result_matchup():
h= request.form['h']
a= request.form['a']
l= request.form['l']
p= request.form['p']
result = json.dumps(new.calc(h,a,l,p))
return render_template('page3.html',result=result)
if __name__ == "__main__":
app.run(debug=True)
当我要求 return result 检查自己时,这是输出:
{"f": 197.1, "k": 196}
这是我的 page3.html:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<center><h1>Final = {{f}}</h1></center>
</body>
</html>
所有这些的输出是 "最终 = " ,而我期望 Final = 197.1.
我做错了什么?有什么帮助吗?
谢谢!
【问题讨论】:
标签: javascript python json flask