當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。