app = Flask(name)
@app.route("/")
@app.route("/hello")
def hello():
return “Hello world! This is a web application by Flask.”
def hello():
#return render_template(“index.html”)
return “”"输入两个数求和
使用表单计算两个数的和
求和
被加数 加数
“”"
app = Flask(name)
@app.route("/")
@app.route("/hello")
def hello():
return “Hello world! This is a web application by Flask.”
####def hello():
#return render_template(“index.html”)
return “”"
输入两个数求和
使用表单计算两个数的和
被加数
加数
求和
“”"
@app.route("/add", methods=[‘GET’, ‘POST’])
def add():
n1 = int(request.form[‘n1’])
n2 = int(request.form[‘n2’])
n3 = n1 + n2
return render_template(“add.html”, n1=n1, n2=n2, n3=n3)
.> return “”"
输入两个数求和
使用表单计算两个数的和
被加数
if name == “main”:
app.run()
@app.route("/add", methods=[‘GET’, ‘POST’])
def add():
n1 = int(request.form[‘n1’])
n2 = int(request.form[‘n2’])
n3 = n1 + n2
return render_template(“add.html”, n1=n1, n2=n2, n3=n3)
return “”"
输入两个数求和
使用表单计算两个数的和
被加数<input type=‘text’ name=‘n1’ value = “”"+str(n1)+""" />
加数<input type=‘text’ name=‘n2’ value = “”"+str(n2)+""" />
和<input type=‘text’ name=‘n3’ value= “”"+str(n3)+""" />
home
“”"
if name == “main”:
app.run()