请求当前路线,包括查询字符串?
我一直在 Pyramid API 中查找,但找不到一种方法可以让我提取用户地址栏中的 url,特别是包括查询字符串。有没有一种方法我一直在浏览?
http://docs.pylonsproject.org/projects/pyramid/dev/api /request.html
I've been looking in the Pyramid API and haven't been able to find a method that allows me to extract the url in the user's address bar, specifically including the query strings. Is there a method I keep skimming across?
http://docs.pylonsproject.org/projects/pyramid/dev/api/request.html
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
听起来您只需要
request.url
这是用户在地址栏中输入的任何内容。request.GET
是查询字符串中键/值的字典。request.POST
是请求正文中键/值的字典。request.params
是两者组合的字典。这可能在 webob 文档中得到更好的解释,这实际上是 Pyramid 用于其请求和响应对象的内容。
http://docs.webob.org/en/latest/index.html
It sounds like you just want
request.url
which is whatever the user typed in the address bar.request.GET
is a dictionary of key/values in the query string.request.POST
is a dictionary of key/values in the request body.request.params
is a dictionary of the combination of both.This might be better explained in the webob documentation, which is effectively what Pyramid is using for its request and response objects.
http://docs.webob.org/en/latest/index.html
现在,如果您只需要
?
之后的 URL 编码文本(即id=10&name=Bob
),则可以使用request.query_string
http://docs.pylonsproject.org/projects/pyramid/ zh/latest/narr/webob.html
Now one can use
request.query_string
if you only want the URL-encoded text after the?
(ieid=10&name=Bob
)http://docs.pylonsproject.org/projects/pyramid/en/latest/narr/webob.html