我试图从window.history.pushState所做的更改放到烧瓶服务器上。例如,如果我这样做:烧瓶接收来自pushstate的url更改
window.history.pushState("object or string", "Title", "?firstchange=done");
如何在烧瓶中获得“完成”字符串?我在客户端路由下有一个模板,并且我想要一个函数在可用时获取firstchange查询字符串。
@app.route("/client")
def initial_template():
return render_template('client.html')
@app.route("/client")
def get_change():
print request.args.get('firstchange')
,当我的网址更改为http://127.0.0.1:5000/client?firstchange=done后调用这个在其它函数的返回是“无”,而不是“完成”。
编辑:
你如何使用
window.location.href('127.0.0.1:5000/client?firstchange=done')
用同样的方法烧瓶我仍然得到“没有”的回报做到这一点。我能否在其他方法中使用get_change方法来确定查询字符串值?
推送状态发生在客户端,Flask只是服务器端。你必须做'window.location.href('/ client?firstchange = done')'或使用AJAX。 – nathancahill
请参阅编辑新问题。 – shell