當前位置: 首頁>>代碼示例>>Python>>正文


Python urls.url_quote方法代碼示例

本文整理匯總了Python中werkzeug.urls.url_quote方法的典型用法代碼示例。如果您正苦於以下問題:Python urls.url_quote方法的具體用法?Python urls.url_quote怎麽用?Python urls.url_quote使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在werkzeug.urls的用法示例。


在下文中一共展示了urls.url_quote方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: post

# 需要導入模塊: from werkzeug import urls [as 別名]
# 或者: from werkzeug.urls import url_quote [as 別名]
def post(self):
        if not may(CREATE):
            raise Forbidden()
        lang = request.form.get('language')
        content_type = self.TRANS.get(lang)
        content_type_hint = 'text/plain'
        filename = None
        t = request.form['code']
        # t is already unicode, but we want utf-8 for storage
        t = t.encode('utf-8')
        size = len(t)
        f = BytesIO(t)
        maxlife_timestamp = FOREVER
        name = create_item(f, filename, size, content_type, content_type_hint,
                           maxlife_stamp=maxlife_timestamp)
        return redirect_next('bepasty.display', name=name, _anchor=url_quote(filename)) 
開發者ID:bepasty,項目名稱:bepasty-server,代碼行數:18,代碼來源:lodgeit.py

示例2: make_redirect_url

# 需要導入模塊: from werkzeug import urls [as 別名]
# 或者: from werkzeug.urls import url_quote [as 別名]
def make_redirect_url(self, path_info, query_args=None, domain_part=None):
        """Creates a redirect URL.

        :internal:
        """
        suffix = ''
        if query_args:
            suffix = '?' + self.encode_query_args(query_args)
        return str('%s://%s/%s%s' % (
            self.url_scheme,
            self.get_host(domain_part),
            posixpath.join(self.script_name[:-1].lstrip('/'),
                           url_quote(path_info.lstrip('/'), self.map.charset,
                                     safe='/:|+')),
            suffix
        )) 
開發者ID:googlearchive,項目名稱:cloud-playground,代碼行數:18,代碼來源:routing.py

示例3: get_query_string

# 需要導入模塊: from werkzeug import urls [as 別名]
# 或者: from werkzeug.urls import url_quote [as 別名]
def get_query_string(environ):
    """Returns the `QUERY_STRING` from the WSGI environment.  This also takes
    care about the WSGI decoding dance on Python 3 environments as a
    native string.  The string returned will be restricted to ASCII
    characters.

    .. versionadded:: 0.9

    :param environ: the WSGI environment object to get the query string from.
    """
    qs = wsgi_get_bytes(environ.get('QUERY_STRING', ''))
    # QUERY_STRING really should be ascii safe but some browsers
    # will send us some unicode stuff (I am looking at you IE).
    # In that case we want to urllib quote it badly.
    return try_coerce_native(url_quote(qs, safe=':&%=+$!*\'(),')) 
開發者ID:jpush,項目名稱:jbox,代碼行數:17,代碼來源:wsgi.py

示例4: build

# 需要導入模塊: from werkzeug import urls [as 別名]
# 或者: from werkzeug.urls import url_quote [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

示例5: to_url

# 需要導入模塊: from werkzeug import urls [as 別名]
# 或者: from werkzeug.urls import url_quote [as 別名]
def to_url(self, value):
        return url_quote(value, charset=self.map.charset) 
開發者ID:jpush,項目名稱:jbox,代碼行數:4,代碼來源:routing.py

示例6: quote

# 需要導入模塊: from werkzeug import urls [as 別名]
# 或者: from werkzeug.urls import url_quote [as 別名]
def quote(self, value):
        if self.has_slug:
            return self.model.slug.slugify(value)
        else:
            return url_quote(value) 
開發者ID:opendatateam,項目名稱:udata,代碼行數:7,代碼來源:routing.py

示例7: build

# 需要導入模塊: from werkzeug import urls [as 別名]
# 或者: from werkzeug.urls import url_quote [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

示例8: send_file_inline

# 需要導入模塊: from werkzeug import urls [as 別名]
# 或者: from werkzeug.urls import url_quote [as 別名]
def send_file_inline(filename):
    """Send a file inline, including the original filename.

    Ref: http://test.greenbytes.de/tech/tc2231/.
    """
    try:
        response = send_file(filename)
    except FileNotFoundError:
        return abort(404)
    basename = os.path.basename(filename)
    cont_disp = f"inline; filename*=UTF-8''{url_quote(basename)}"
    response.headers["Content-Disposition"] = cont_disp
    return response 
開發者ID:beancount,項目名稱:fava,代碼行數:15,代碼來源:__init__.py


注:本文中的werkzeug.urls.url_quote方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。