本文整理匯總了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')