所以基本上我希望能够输入URL http://example.com/“东西”,如果没有什么渲染index.html。由于某种原因,这是行不通的。 另一方面,我希望能够传递该参数,例如http://example.com/host123并在下面的结果函数中使用它。理想情况下,我可以直接输入URL example.com/host123并直接进入该页面。如何将URL中的参数传递给Flask中的其他函数
@app.route('/<host>',methods= ['POST', 'GET'])
15 def index(host):
16 if host is None:
17 return render_template("index.html")
18 else:
19 return result(host)
20 print("test")
21 @app.route('/<host>',methods= ['POST', 'GET'])
22 def result(host):
#some code....
感谢帮忙的人,我会尽力的。 – BeastlyBernardo