【发布时间】:2017-11-22 05:25:31
【问题描述】:
所以基本上我希望能够输入 URL,例如http://example.com/"something",如果没有,则渲染 index.html。由于某种原因,这不起作用。 另一方面,我希望能够传递该参数,例如http://example.com/host123 并在下面的结果函数中使用它。理想情况下,最后我可以简单地输入 URL example.com/host123 并直接将我带到该页面。
@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....
【问题讨论】: