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


Python urls.url_encode方法代码示例

本文整理汇总了Python中werkzeug.urls.url_encode方法的典型用法代码示例。如果您正苦于以下问题:Python urls.url_encode方法的具体用法?Python urls.url_encode怎么用?Python urls.url_encode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在werkzeug.urls的用法示例。


在下文中一共展示了urls.url_encode方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: dispatch_url

# 需要导入模块: from werkzeug import urls [as 别名]
# 或者: from werkzeug.urls import url_encode [as 别名]
def dispatch_url(self, url_string):
        url, url_adapter, query_args = self.parse_url(url_string)

        try:
            endpoint, kwargs = url_adapter.match()
        except NotFound:
            raise NotSupported(url_string)
        except RequestRedirect as e:
            new_url = "{0.new_url}?{1}".format(e, url_encode(query_args))
            return self.dispatch_url(new_url)

        try:
            handler = import_string(endpoint)
            request = Request(url=url, args=query_args)
            return handler(request, **kwargs)
        except RequestRedirect as e:
            return self.dispatch_url(e.new_url) 
开发者ID:dongweiming,项目名称:daenerys,代码行数:19,代码来源:app.py

示例2: request_authentication

# 需要导入模块: from werkzeug import urls [as 别名]
# 或者: from werkzeug.urls import url_encode [as 别名]
def request_authentication(
        self, redirect_url: str
    ) -> AuthenticationContinuation:
        auth_nonce = ''.join(map('{:02x}'.format, os.urandom(16)))
        self.states.append((auth_nonce, redirect_url))
        url = 'http://example.com/auth/?' + url_encode({
            'auth_nonce': auth_nonce,
            'redirect_url': redirect_url
        })
        return AuthenticationContinuation(url, auth_nonce) 
开发者ID:spoqa,项目名称:geofront,代码行数:12,代码来源:server_test.py

示例3: request_authentication

# 需要导入模块: from werkzeug import urls [as 别名]
# 或者: from werkzeug.urls import url_encode [as 别名]
def request_authentication(
        self, redirect_url: str
    ) -> AuthenticationContinuation:
        auth_nonce = ''.join(map('{:02x}'.format, os.urandom(16)))
        query = url_encode({
            'client_id': self.client_id,
            'redirect_uri': redirect_url,
            'scope': self.authorize_scope,
            'state': auth_nonce,
            'response_type': 'code',
        })
        authorize_url = '{}?{}'.format(self.authorize_url, query)
        return AuthenticationContinuation(authorize_url, auth_nonce) 
开发者ID:spoqa,项目名称:geofront,代码行数:15,代码来源:oauth.py

示例4: request_authentication

# 需要导入模块: from werkzeug import urls [as 别名]
# 或者: from werkzeug.urls import url_encode [as 别名]
def request_authentication(
        self, redirect_url: str
    ) -> AuthenticationContinuation:
        response = self.request('POST', self.REQUEST_TOKEN_URL.format(self))
        request_token = url_decode_stream(response)
        response.close()
        return AuthenticationContinuation(
            self.AUTHORIZE_URL.format(self) + '?' + url_encode({
                'oauth_token': request_token['oauth_token'],
                'oauth_callback': redirect_url
            }),
            (request_token['oauth_token'], request_token['oauth_token_secret'])
        ) 
开发者ID:spoqa,项目名称:geofront,代码行数:15,代码来源:stash.py

示例5: build

# 需要导入模块: from werkzeug import urls [as 别名]
# 或者: from werkzeug.urls import url_encode [as 别名]
def build(self, values, append_unknown=True):
        """Assembles the relative url for that rule and the subdomain.
        If building doesn't work for some reasons `None` is returned.

        :internal:
        """
        tmp = []
        add = tmp.append
        processed = set(self.arguments)
        for is_dynamic, data in self._trace:
            if is_dynamic:
                try:
                    add(self._converters[data].to_url(values[data]))
                except ValidationError:
                    return
                processed.add(data)
            else:
                add(url_quote(to_bytes(data, self.map.charset), safe='/:|+'))
        domain_part, url = (u''.join(tmp)).split(u'|', 1)

        if append_unknown:
            query_vars = MultiDict(values)
            for key in processed:
                if key in query_vars:
                    del query_vars[key]

            if query_vars:
                url += u'?' + url_encode(query_vars, charset=self.map.charset,
                                         sort=self.map.sort_parameters,
                                         key=self.map.sort_key)

        return domain_part, url 
开发者ID:jpush,项目名称:jbox,代码行数:34,代码来源:routing.py

示例6: encode_query_args

# 需要导入模块: from werkzeug import urls [as 别名]
# 或者: from werkzeug.urls import url_encode [as 别名]
def encode_query_args(self, query_args):
        if not isinstance(query_args, string_types):
            query_args = url_encode(query_args, self.map.charset)
        return query_args 
开发者ID:jpush,项目名称:jbox,代码行数:6,代码来源:routing.py

示例7: login_url

# 需要导入模块: from werkzeug import urls [as 别名]
# 或者: from werkzeug.urls import url_encode [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

示例8: _build_url

# 需要导入模块: from werkzeug import urls [as 别名]
# 或者: from werkzeug.urls import url_encode [as 别名]
def _build_url(self, url, kwargs):
        if 'qs' not in kwargs:
            return url
        qs = kwargs.pop('qs')
        return '?'.join([url, url_encode(qs)]) 
开发者ID:opendatateam,项目名称:udata,代码行数:7,代码来源:plugin.py

示例9: delete_query

# 需要导入模块: from werkzeug import urls [as 别名]
# 或者: from werkzeug.urls import url_encode [as 别名]
def delete_query(*new_values):
    args = request.args.copy()

    for key in new_values:
        del args[key]

    return '{}?{}'.format(request.path, url_encode(args)) 
开发者ID:certsocietegenerale,项目名称:fame,代码行数:9,代码来源:webserver.py

示例10: modify_query

# 需要导入模块: from werkzeug import urls [as 别名]
# 或者: from werkzeug.urls import url_encode [as 别名]
def modify_query(key, value):
    args = request.args.copy()
    args[key] = value

    return '{}?{}'.format(request.path, url_encode(args)) 
开发者ID:certsocietegenerale,项目名称:fame,代码行数:7,代码来源:webserver.py

示例11: build

# 需要导入模块: from werkzeug import urls [as 别名]
# 或者: from werkzeug.urls import url_encode [as 别名]
def build(self, values, append_unknown=True):
        """Assembles the relative url for that rule and the subdomain.
        If building doesn't work for some reasons `None` is returned.

        :internal:
        """
        tmp = []
        add = tmp.append
        processed = set(self.arguments)
        for is_dynamic, data in self._trace:
            if is_dynamic:
                try:
                    add(self._converters[data].to_url(values[data]))
                except ValidationError:
                    return
                processed.add(data)
            else:
                add(url_quote(to_bytes(data, self.map.charset), safe='/:|+'))
        domain_part, url = (u''.join(tmp)).split(u'|', 1)

        if append_unknown:
            query_vars = MultiDict(values)
            for key in processed:
                if key in query_vars:
                    del query_vars[key]

            if query_vars:
                url += u'?' + url_encode(query_vars, charset=self.map.charset,
                                        sort=self.map.sort_parameters,
                                        key=self.map.sort_key)

        return domain_part, url 
开发者ID:chalasr,项目名称:Flask-P2P,代码行数:34,代码来源:routing.py

示例12: test_run_template_http_url

# 需要导入模块: from werkzeug import urls [as 别名]
# 或者: from werkzeug.urls import url_encode [as 别名]
def test_run_template_http_url(app, dataflow_job_name):
    args = {
        'project': PROJECT,
        'job': dataflow_job_name,
        'template': 'gs://dataflow-templates/latest/Word_Count',
        'inputFile': 'gs://apache-beam-samples/shakespeare/kinglear.txt',
        'output': 'gs://{}/dataflow/wordcount/outputs'.format(BUCKET),
    }
    with app.test_request_context('/?' + url_encode(args)):
        res = main.run_template(flask.request)
        data = json.loads(res)
        assert 'test_run_template_url' in data['job']['name'] 
开发者ID:GoogleCloudPlatform,项目名称:python-docs-samples,代码行数:14,代码来源:main_test.py

示例13: modify_query

# 需要导入模块: from werkzeug import urls [as 别名]
# 或者: from werkzeug.urls import url_encode [as 别名]
def modify_query(**new_values):
    args = flask.request.args.copy()

    args.pop('p', None)

    for key, value in new_values.items():
        args[key] = value

    return '{}?{}'.format(flask.request.path, url_encode(args)) 
开发者ID:nyaadevs,项目名称:nyaa,代码行数:11,代码来源:template_utils.py


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