【发布时间】:2020-10-04 11:25:46
【问题描述】:
我正在尝试将“#”符号解析为 Flask 项目中的直接 url。问题是每次请求 url 时,它都会破坏任何具有 #init 的值,因为它是 url 编码中的特殊字符。
localhost:9999/match/keys?source=#123&destination=#123
在烧瓶中,我试图像这样得到这些参数
app.route(f'/match/keys/source=<string:start>/destination=<string:end>', methods=['GET'])
我在控制台上看到的 url 响应是这样的:
"GET /match/keys/source=' HTTP/1.0" 404 -] happens
【问题讨论】:
-
尝试使用
%23作为“#”字符 -
请注意,您在烧瓶中捕获查询字符串,就像
request.args.get('source') -
我认为该路由不是有效路由,它也应该是
/match/keys, methods=['GET'],您使用request.args.get('source')获取查询字符串值
标签: python url flask url-routing