当前位置: 首页>>代码示例>>Python>>正文


Python urls.url_decode方法代码示例

本文整理汇总了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',
        }) 
开发者ID:opendatateam,项目名称:udata,代码行数:21,代码来源:test_query.py

示例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',
        }) 
开发者ID:opendatateam,项目名称:udata,代码行数:20,代码来源:test_query.py

示例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',
        }) 
开发者ID:opendatateam,项目名称:udata,代码行数:20,代码来源:test_query.py

示例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',
        }) 
开发者ID:opendatateam,项目名称:udata,代码行数:19,代码来源:test_query.py

示例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',
        }) 
开发者ID:opendatateam,项目名称:udata,代码行数:20,代码来源:test_query.py

示例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 
开发者ID:pgjones,项目名称:quart,代码行数:41,代码来源:base.py

示例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('>')]} 
开发者ID:spoqa,项目名称:geofront,代码行数:16,代码来源:server_test.py

示例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) 
开发者ID:jpush,项目名称:jbox,代码行数:12,代码来源:wrappers.py

示例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) 
开发者ID:jpush,项目名称:jbox,代码行数:31,代码来源:flask_login.py

示例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) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:15,代码来源:wrappers.py

示例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 
开发者ID:dongweiming,项目名称:daenerys,代码行数:10,代码来源:app.py

示例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') 
开发者ID:GeekTrainer,项目名称:Flask,代码行数:15,代码来源:urls.py


注:本文中的werkzeug.urls.url_decode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。