Python 烧瓶:散列“#&引用;在路由中
我最近正在使用GoogleAPI,并使用简单的flask方法检索一些id_令牌 以下是我的代码和注释中的解释:Python 烧瓶:散列“#&引用;在路由中,python,url,flask,routing,url-routing,Python,Url,Flask,Routing,Url Routing,我最近正在使用GoogleAPI,并使用简单的flask方法检索一些id_令牌 以下是我的代码和注释中的解释: @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
@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\u令牌
重定向到http://localhost:8000/afterlogin/#id_token=some_id_token
但出于某种原因,它显示了404错误。
我想这是因为url中的“#”,我想要id\u标记。我知道html中的“#”表示“href”中的路径链接或路由
所以我试过了
@app.route('/afterlogin/<path:id>')
@app.route(“/afterlogin/”)
但错误依然存在
有什么猜测吗?在浏览器本地处理#
之后,所有内容都不会发送到服务器,因此无法在路由中使用它。省略#
:
在#
被浏览器本地处理之后,所有内容都不会发送到服务器,因此您不能在路由中使用它。省略#
:
URL中的
未发送到服务器后的所有内容,您不能在路由中使用它。@Barmar将其作为答案提交我已通过尝试http://localhost:8000/afterlogin/#hello
显示我没有找到,而且有趣的是,当我尝试http://localhost:8000/afterlogin/hey#hello
它打印出嘿
@jamylak我不知道Flask,所以我不知道如何纠正他在做什么。查询参数似乎是显而易见的选择,然后URL中#
之后的所有内容都不会发送到服务器,您不能在路由中使用它。@Barmar将其作为应答提交。我已通过尝试http://localhost:8000/afterlogin/#hello
它显示我没有找到,而且有趣的是,当我尝试http://localhost:8000/afterlogin/hey#hello
它打印出嘿
@jamylak我不知道,所以我不知道如何纠正他在做什么。查询参数似乎是显而易见的选择
http://localhost:8000/afterlogin/some_id_token