本文整理汇总了Python中werkzeug.urls.url_decode方法的典型用法代码示例。如果您正苦于以下问题:Python urls.url_decode方法的具体用法?Python urls.url_decode怎么用?Python urls.url_decode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类werkzeug.urls
的用法示例。
在下文中一共展示了urls.url_decode方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_to_url
# 需要导入模块: from werkzeug import urls [as 别名]
# 或者: from werkzeug.urls import url_decode [as 别名]
def test_to_url(self, app):
kwargs = {
'q': 'test',
'tag': ['tag1', 'tag2'],
'page': 2,
'facets': True,
}
search_query = search.search_for(FakeSearch, **kwargs)
with app.test_request_context('/an_url'):
url = search_query.to_url()
parsed_url = url_parse(url)
qs = url_decode(parsed_url.query)
assert parsed_url.path == '/an_url'
assert_json_equal(multi_to_dict(qs), {
'q': 'test',
'tag': ['tag1', 'tag2'],
'page': '2',
})
示例2: test_to_url_with_override
# 需要导入模块: from werkzeug import urls [as 别名]
# 或者: from werkzeug.urls import url_decode [as 别名]
def test_to_url_with_override(self, app):
kwargs = {
'q': 'test',
'tag': ['tag1', 'tag2'],
'page': 2,
}
search_query = search.search_for(FakeSearch, **kwargs)
with app.test_request_context('/an_url'):
url = search_query.to_url(tag='tag3', other='value')
parsed_url = url_parse(url)
qs = url_decode(parsed_url.query)
assert parsed_url.path == '/an_url'
assert_json_equal(multi_to_dict(qs), {
'q': 'test',
'tag': ['tag1', 'tag2', 'tag3'],
'other': 'value',
})
示例3: test_to_url_with_override_and_replace
# 需要导入模块: from werkzeug import urls [as 别名]
# 或者: from werkzeug.urls import url_decode [as 别名]
def test_to_url_with_override_and_replace(self, app):
kwargs = {
'q': 'test',
'tag': ['tag1', 'tag2'],
'page': 2,
}
search_query = search.search_for(FakeSearch, **kwargs)
with app.test_request_context('/an_url'):
url = search_query.to_url(tag='tag3', other='value', replace=True)
parsed_url = url_parse(url)
qs = url_decode(parsed_url.query)
assert parsed_url.path == '/an_url'
assert_json_equal(multi_to_dict(qs), {
'q': 'test',
'tag': 'tag3',
'other': 'value',
})
示例4: test_to_url_with_none
# 需要导入模块: from werkzeug import urls [as 别名]
# 或者: from werkzeug.urls import url_decode [as 别名]
def test_to_url_with_none(self, app):
kwargs = {
'q': 'test',
'tag': ['tag1', 'tag2'],
'page': 2,
}
search_query = search.search_for(FakeSearch, **kwargs)
with app.test_request_context('/an_url'):
url = search_query.to_url(tag=None, other='value', replace=True)
parsed_url = url_parse(url)
qs = url_decode(parsed_url.query)
assert parsed_url.path == '/an_url'
assert_json_equal(multi_to_dict(qs), {
'q': 'test',
'other': 'value',
})
示例5: test_to_url_with_specified_url
# 需要导入模块: from werkzeug import urls [as 别名]
# 或者: from werkzeug.urls import url_decode [as 别名]
def test_to_url_with_specified_url(self, app):
kwargs = {
'q': 'test',
'tag': ['tag1', 'tag2'],
'page': 2,
}
search_query = search.search_for(FakeSearch, **kwargs)
with app.test_request_context('/an_url'):
url = search_query.to_url('/another_url')
parsed_url = url_parse(url)
qs = url_decode(parsed_url.query)
assert parsed_url.path == '/another_url'
assert_json_equal(multi_to_dict(qs), {
'q': 'test',
'tag': ['tag1', 'tag2'],
'page': '2',
})
示例6: __init__
# 需要导入模块: from werkzeug import urls [as 别名]
# 或者: from werkzeug.urls import url_decode [as 别名]
def __init__(
self,
method: str,
scheme: str,
path: str,
query_string: bytes,
headers: Headers,
root_path: str,
http_version: str,
) -> None:
"""Create a request or websocket base object.
Arguments:
method: The HTTP verb.
scheme: The scheme used for the request.
path: The full unquoted path of the request.
query_string: The raw bytes for the query string part.
headers: The request headers.
root_path: The root path that should be prepended to all
routes.
http_version: The HTTP version of the request.
Attributes:
args: The query string arguments.
scheme: The URL scheme, http or https.
"""
super().__init__(headers)
self.args = url_decode(
query_string,
self.url_charset,
errors=self.encoding_errors,
cls=self.parameter_storage_class,
)
self.path = path
self.query_string = query_string
self.scheme = scheme
self.method = method
self.root_path = root_path
self.http_version = http_version
示例7: test_create_access_token
# 需要导入模块: from werkzeug import urls [as 别名]
# 或者: from werkzeug.urls import url_decode [as 别名]
def test_create_access_token(fx_app, fx_token_id) -> None:
url = get_url('create_access_token', token_id=fx_token_id)
with app.test_client() as c:
response = c.put(url)
assert response.status_code == 202
link = response.headers['Link']
assert link.startswith('<http://example.com/auth/')
assert link.endswith('>; rel=next')
qs = url_decode(link[link.find('?') + 1:link.find('>')])
result = json.loads(response.get_data())
assert qs['redirect_url'] == get_url('authenticate',
token_id=fx_token_id,
_external=True)
assert result == {'next_url': link[1:link.find('>')]}
示例8: args
# 需要导入模块: from werkzeug import urls [as 别名]
# 或者: from werkzeug.urls import url_decode [as 别名]
def args(self):
"""The parsed URL parameters. By default an
:class:`~werkzeug.datastructures.ImmutableMultiDict`
is returned from this function. This can be changed by setting
:attr:`parameter_storage_class` to a different type. This might
be necessary if the order of the form data is important.
"""
return url_decode(wsgi_get_bytes(self.environ.get('QUERY_STRING', '')),
self.url_charset, errors=self.encoding_errors,
cls=self.parameter_storage_class)
示例9: login_url
# 需要导入模块: from werkzeug import urls [as 别名]
# 或者: from werkzeug.urls import url_decode [as 别名]
def login_url(login_view, next_url=None, next_field='next'):
'''
Creates a URL for redirecting to a login page. If only `login_view` is
provided, this will just return the URL for it. If `next_url` is provided,
however, this will append a ``next=URL`` parameter to the query string
so that the login view can redirect back to that URL.
:param login_view: The name of the login view. (Alternately, the actual
URL to the login view.)
:type login_view: str
:param next_url: The URL to give the login view for redirection.
:type next_url: str
:param next_field: What field to store the next URL in. (It defaults to
``next``.)
:type next_field: str
'''
if login_view.startswith(('https://', 'http://', '/')):
base = login_view
else:
base = url_for(login_view)
if next_url is None:
return base
parts = list(urlparse(base))
md = url_decode(parts[4])
md[next_field] = make_next_param(base, next_url)
parts[4] = url_encode(md, sort=True)
return urlunparse(parts)
示例10: args
# 需要导入模块: from werkzeug import urls [as 别名]
# 或者: from werkzeug.urls import url_decode [as 别名]
def args(self):
"""The parsed URL parameters (the part in the URL after the question
mark).
By default an
:class:`~werkzeug.datastructures.ImmutableMultiDict`
is returned from this function. This can be changed by setting
:attr:`parameter_storage_class` to a different type. This might
be necessary if the order of the form data is important.
"""
return url_decode(wsgi_get_bytes(self.environ.get('QUERY_STRING', '')),
self.url_charset, errors=self.encoding_errors,
cls=self.parameter_storage_class)
示例11: parse_url
# 需要导入模块: from werkzeug import urls [as 别名]
# 或者: from werkzeug.urls import url_decode [as 别名]
def parse_url(self, url_string):
url = urlparse(url_string)
url = self.validate_url(url)
url_adapter = self.url_map.bind(server_name=url.hostname,
url_scheme=url.scheme,
path_info=url.path)
query_args = url_decode(url.query)
return url, url_adapter, query_args
示例12: test_url_decoding
# 需要导入模块: from werkzeug import urls [as 别名]
# 或者: from werkzeug.urls import url_decode [as 别名]
def test_url_decoding(self):
x = urls.url_decode(b'foo=42&bar=23&uni=H%C3%A4nsel')
self.assert_strict_equal(x['foo'], u'42')
self.assert_strict_equal(x['bar'], u'23')
self.assert_strict_equal(x['uni'], u'Hänsel')
x = urls.url_decode(b'foo=42;bar=23;uni=H%C3%A4nsel', separator=b';')
self.assert_strict_equal(x['foo'], u'42')
self.assert_strict_equal(x['bar'], u'23')
self.assert_strict_equal(x['uni'], u'Hänsel')
x = urls.url_decode(b'%C3%9Ch=H%C3%A4nsel', decode_keys=True)
self.assert_strict_equal(x[u'Üh'], u'Hänsel')