flask:路由中的哈希“#”
flask: hashes "#" in the routing
我最近在使用 google API 并使用简单的烧瓶方法检索一些 id_token。
这是我的代码,注释中有解释:
@app.route('/afterlogin/id_token')
def afterlogin(id): # get the id
print(id) # print it
return render_template(r'creds_view.html', data=id) # and render the template with 'id' in it (for test purposes)
所以发生的事情是,在用户登录后,api 将 id_token
重定向到 http://localhost:8000/afterlogin/#id_token=some_id_token
。
但出于某种原因,它向我显示 404 错误。
我认为这是因为 url 中的“#”,我想要 id_token
。我知道 html 中的“#”表示 'href' 中的路径链接或路由。
所以我试过了。
@app.route('/afterlogin/<path:id>')
但错误仍然存在。
有什么猜测吗?
#
之后的所有内容都由浏览器在本地处理,不会发送到服务器,所以不能在路由中使用。省略 #
:
http://localhost:8000/afterlogin/some_id_token
我最近在使用 google API 并使用简单的烧瓶方法检索一些 id_token。
这是我的代码,注释中有解释:
@app.route('/afterlogin/id_token')
def afterlogin(id): # get the id
print(id) # print it
return render_template(r'creds_view.html', data=id) # and render the template with 'id' in it (for test purposes)
所以发生的事情是,在用户登录后,api 将 id_token
重定向到 http://localhost:8000/afterlogin/#id_token=some_id_token
。
但出于某种原因,它向我显示 404 错误。
我认为这是因为 url 中的“#”,我想要 id_token
。我知道 html 中的“#”表示 'href' 中的路径链接或路由。
所以我试过了。
@app.route('/afterlogin/<path:id>')
但错误仍然存在。
有什么猜测吗?
#
之后的所有内容都由浏览器在本地处理,不会发送到服务器,所以不能在路由中使用。省略 #
:
http://localhost:8000/afterlogin/some_id_token