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

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

示例1: _unquote_or_none

​點讚 5

# 需要導入模塊: from tornado import escape [as 別名]

# 或者: from tornado.escape import url_unescape [as 別名]

def _unquote_or_none(s):

"""None-safe wrapper around url_unescape to handle unamteched optional

groups correctly.

Note that args are passed as bytes so the handler can decide what

encoding to use.

"""

if s is None:

return s

return escape.url_unescape(s, encoding=None, plus=False)

開發者ID:tao12345666333,項目名稱:tornado-zh,代碼行數:12,

示例2: environ

​點讚 5

# 需要導入模塊: from tornado import escape [as 別名]

# 或者: from tornado.escape import url_unescape [as 別名]

def environ(request):

"""Converts a `tornado.httputil.HTTPServerRequest` to a WSGI environment.

"""

hostport = request.host.split(":")

if len(hostport) == 2:

host = hostport[0]

port = int(hostport[1])

else:

host = request.host

port = 443 if request.protocol == "https" else 80

environ = {

"REQUEST_METHOD": request.method,

"SCRIPT_NAME": "",

"PATH_INFO": to_wsgi_str(escape.url_unescape(

request.path, encoding=None, plus=False)),

"QUERY_STRING": request.query,

"REMOTE_ADDR": request.remote_ip,

"SERVER_NAME": host,

"SERVER_PORT": str(port),

"SERVER_PROTOCOL": request.version,

"wsgi.version": (1, 0),

"wsgi.url_scheme": request.protocol,

"wsgi.input": BytesIO(escape.utf8(request.body)),

"wsgi.errors": sys.stderr,

"wsgi.multithread": False,

"wsgi.multiprocess": True,

"wsgi.run_once": False,

}

if "Content-Type" in request.headers:

environ["CONTENT_TYPE"] = request.headers.pop("Content-Type")

if "Content-Length" in request.headers:

environ["CONTENT_LENGTH"] = request.headers.pop("Content-Length")

for key, value in request.headers.items():

environ["HTTP_" + key.replace("-", "_").upper()] = value

return environ

開發者ID:tao12345666333,項目名稱:tornado-zh,代碼行數:37,

示例3: test_url_unescape_unicode

​點讚 5

# 需要導入模塊: from tornado import escape [as 別名]

# 或者: from tornado.escape import url_unescape [as 別名]

def test_url_unescape_unicode(self):

tests = [

('%C3%A9', u('\u00e9'), 'utf8'),

('%C3%A9', u('\u00c3\u00a9'), 'latin1'),

('%C3%A9', utf8(u('\u00e9')), None),

]

for escaped, unescaped, encoding in tests:

# input strings to url_unescape should only contain ascii

# characters, but make sure the function accepts both byte

# and unicode strings.

self.assertEqual(url_unescape(to_unicode(escaped), encoding), unescaped)

self.assertEqual(url_unescape(utf8(escaped), encoding), unescaped)

開發者ID:tao12345666333,項目名稱:tornado-zh,代碼行數:14,

示例4: test_url_escape_quote_plus

​點讚 5

# 需要導入模塊: from tornado import escape [as 別名]

# 或者: from tornado.escape import url_unescape [as 別名]

def test_url_escape_quote_plus(self):

unescaped = '+ #%'

plus_escaped = '%2B+%23%25'

escaped = '%2B%20%23%25'

self.assertEqual(url_escape(unescaped), plus_escaped)

self.assertEqual(url_escape(unescaped, plus=False), escaped)

self.assertEqual(url_unescape(plus_escaped), unescaped)

self.assertEqual(url_unescape(escaped, plus=False), unescaped)

self.assertEqual(url_unescape(plus_escaped, encoding=None),

utf8(unescaped))

self.assertEqual(url_unescape(escaped, encoding=None, plus=False),

utf8(unescaped))

開發者ID:tao12345666333,項目名稱:tornado-zh,代碼行數:14,

示例5: environ

​點讚 5

# 需要導入模塊: from tornado import escape [as 別名]

# 或者: from tornado.escape import url_unescape [as 別名]

def environ(request: httputil.HTTPServerRequest) -> Dict[Text, Any]:

"""Converts a `tornado.httputil.HTTPServerRequest` to a WSGI environment.

"""

hostport = request.host.split(":")

if len(hostport) == 2:

host = hostport[0]

port = int(hostport[1])

else:

host = request.host

port = 443 if request.protocol == "https" else 80

environ = {

"REQUEST_METHOD": request.method,

"SCRIPT_NAME": "",

"PATH_INFO": to_wsgi_str(

escape.url_unescape(request.path, encoding=None, plus=False)

),

"QUERY_STRING": request.query,

"REMOTE_ADDR": request.remote_ip,

"SERVER_NAME": host,

"SERVER_PORT": str(port),

"SERVER_PROTOCOL": request.version,

"wsgi.version": (1, 0),

"wsgi.url_scheme": request.protocol,

"wsgi.input": BytesIO(escape.utf8(request.body)),

"wsgi.errors": sys.stderr,

"wsgi.multithread": False,

"wsgi.multiprocess": True,

"wsgi.run_once": False,

}

if "Content-Type" in request.headers:

environ["CONTENT_TYPE"] = request.headers.pop("Content-Type")

if "Content-Length" in request.headers:

environ["CONTENT_LENGTH"] = request.headers.pop("Content-Length")

for key, value in request.headers.items():

environ["HTTP_" + key.replace("-", "_").upper()] = value

return environ

開發者ID:opendevops-cn,項目名稱:opendevops,代碼行數:38,

示例6: _unquote_or_none

​點讚 5

# 需要導入模塊: from tornado import escape [as 別名]

# 或者: from tornado.escape import url_unescape [as 別名]

def _unquote_or_none(s: Optional[str]) -> Optional[bytes]: # noqa: F811

"""None-safe wrapper around url_unescape to handle unmatched optional

groups correctly.

Note that args are passed as bytes so the handler can decide what

encoding to use.

"""

if s is None:

return s

return url_unescape(s, encoding=None, plus=False)

開發者ID:opendevops-cn,項目名稱:opendevops,代碼行數:12,

示例7: environ

​點讚 5

# 需要導入模塊: from tornado import escape [as 別名]

# 或者: from tornado.escape import url_unescape [as 別名]

def environ(request):

"""Converts a `tornado.httpserver.HTTPRequest` to a WSGI environment.

"""

hostport = request.host.split(":")

if len(hostport) == 2:

host = hostport[0]

port = int(hostport[1])

else:

host = request.host

port = 443 if request.protocol == "https" else 80

environ = {

"REQUEST_METHOD": request.method,

"SCRIPT_NAME": "",

"PATH_INFO": to_wsgi_str(escape.url_unescape(

request.path, encoding=None, plus=False)),

"QUERY_STRING": request.query,

"REMOTE_ADDR": request.remote_ip,

"SERVER_NAME": host,

"SERVER_PORT": str(port),

"SERVER_PROTOCOL": request.version,

"wsgi.version": (1, 0),

"wsgi.url_scheme": request.protocol,

"wsgi.input": BytesIO(escape.utf8(request.body)),

"wsgi.errors": sys.stderr,

"wsgi.multithread": False,

"wsgi.multiprocess": True,

"wsgi.run_once": False,

}

if "Content-Type" in request.headers:

environ["CONTENT_TYPE"] = request.headers.pop("Content-Type")

if "Content-Length" in request.headers:

environ["CONTENT_LENGTH"] = request.headers.pop("Content-Length")

for key, value in request.headers.items():

environ["HTTP_" + key.replace("-", "_").upper()] = value

return environ

開發者ID:viewfinderco,項目名稱:viewfinder,代碼行數:37,

示例8: _unquote_or_none

​點讚 5

# 需要導入模塊: from tornado import escape [as 別名]

# 或者: from tornado.escape import url_unescape [as 別名]

def _unquote_or_none(s):

"""None-safe wrapper around url_unescape to handle unmatched optional

groups correctly.

Note that args are passed as bytes so the handler can decide what

encoding to use.

"""

if s is None:

return s

return url_unescape(s, encoding=None, plus=False)

開發者ID:tp4a,項目名稱:teleport,代碼行數:12,

示例9: test_url_unescape

​點讚 5

# 需要導入模塊: from tornado import escape [as 別名]

# 或者: from tornado.escape import url_unescape [as 別名]

def test_url_unescape(self):

tests = [

('%C3%A9', u'\u00e9', 'utf8'),

('%C3%A9', u'\u00c3\u00a9', 'latin1'),

('%C3%A9', utf8(u'\u00e9'), None),

]

for escaped, unescaped, encoding in tests:

# input strings to url_unescape should only contain ascii

# characters, but make sure the function accepts both byte

# and unicode strings.

self.assertEqual(url_unescape(to_unicode(escaped), encoding), unescaped)

self.assertEqual(url_unescape(utf8(escaped), encoding), unescaped)

開發者ID:omererdem,項目名稱:honeything,代碼行數:14,

示例10: get

​點讚 5

# 需要導入模塊: from tornado import escape [as 別名]

# 或者: from tornado.escape import url_unescape [as 別名]

def get(self, token, connection_file):

register_connection_file(token, url_unescape(connection_file))

開發者ID:funkey,項目名稱:nyroglancer,代碼行數:5,

示例11: __call__

​點讚 4

# 需要導入模塊: from tornado import escape [as 別名]

# 或者: from tornado.escape import url_unescape [as 別名]

def __call__(self, request):

"""Called by HTTPServer to execute the request."""

transforms = [t(request) for t in self.transforms]

handler = None

args = []

kwargs = {}

handlers = self._get_host_handlers(request)

if not handlers:

handler = RedirectHandler(

self, request, url="http://" + self.default_host + "/")

else:

for spec in handlers:

match = spec.regex.match(request.path)

if match:

handler = spec.handler_class(self, request, **spec.kwargs)

if spec.regex.groups:

# None-safe wrapper around url_unescape to handle

# unmatched optional groups correctly

def unquote(s):

if s is None:

return s

return escape.url_unescape(s, encoding=None,

plus=False)

# Pass matched groups to the handler. Since

# match.groups() includes both named and unnamed groups,

# we want to use either groups or groupdict but not both.

# Note that args are passed as bytes so the handler can

# decide what encoding to use.

if spec.regex.groupindex:

kwargs = dict(

(str(k), unquote(v))

for (k, v) in match.groupdict().items())

else:

args = [unquote(s) for s in match.groups()]

break

if not handler:

handler = ErrorHandler(self, request, status_code=404)

# In debug mode, re-compile templates and reload static files on every

# request so you don't need to restart to see changes

if self.settings.get("debug"):

with RequestHandler._template_loader_lock:

for loader in RequestHandler._template_loaders.values():

loader.reset()

StaticFileHandler.reset()

handler._execute(transforms, *args, **kwargs)

return handler

開發者ID:viewfinderco,項目名稱:viewfinder,代碼行數:51,

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

python unescape函数_Python escape.url_unescape方法代碼示例相关推荐

  1. python linspace函数_Python torch.linspace方法代碼示例

    本文整理匯總了Python中torch.linspace方法的典型用法代碼示例.如果您正苦於以下問題:Python torch.linspace方法的具體用法?Python torch.linspac ...

  2. python markdown2 样式_Python markdown2.markdown方法代碼示例

    本文整理匯總了Python中markdown2.markdown方法的典型用法代碼示例.如果您正苦於以下問題:Python markdown2.markdown方法的具體用法?Python markd ...

  3. python socketio例子_Python socket.SocketIO方法代碼示例

    本文整理匯總了Python中socket.SocketIO方法的典型用法代碼示例.如果您正苦於以下問題:Python socket.SocketIO方法的具體用法?Python socket.Sock ...

  4. python wheel使用_Python wheel.Wheel方法代碼示例

    # 需要導入模塊: from pip import wheel [as 別名] # 或者: from pip.wheel import Wheel [as 別名] def from_line(cls, ...

  5. python的from_bytes属性_Python parse.quote_from_bytes方法代碼示例

    本文整理匯總了Python中urllib.parse.quote_from_bytes方法的典型用法代碼示例.如果您正苦於以下問題:Python parse.quote_from_bytes方法的具體 ...

  6. python里turtle.circle什么意思_Python turtle.circle方法代碼示例

    本文整理匯總了Python中turtle.circle方法的典型用法代碼示例.如果您正苦於以下問題:Python turtle.circle方法的具體用法?Python turtle.circle怎麽 ...

  7. python中startout是什么意思_Python socket.timeout方法代碼示例

    本文整理匯總了Python中gevent.socket.timeout方法的典型用法代碼示例.如果您正苦於以下問題:Python socket.timeout方法的具體用法?Python socket ...

  8. python dict get default_Python locale.getdefaultlocale方法代碼示例

    本文整理匯總了Python中locale.getdefaultlocale方法的典型用法代碼示例.如果您正苦於以下問題:Python locale.getdefaultlocale方法的具體用法?Py ...

  9. pythonitems方法_Python environ.items方法代碼示例

    本文整理匯總了Python中os.environ.items方法的典型用法代碼示例.如果您正苦於以下問題:Python environ.items方法的具體用法?Python environ.item ...

最新文章

  1. 10行Python代码实现Web自动化管控
  2. python turtle画气球-python windows下显示托盘区气球消息
  3. python怎么安装包-Python-如何离线安装软件包?
  4. Leetcode 38.外观数列 (每日一题 20210702)
  5. 【题解】跳房子-C++
  6. aliyun gradle 代理_android studio gradle国内代理设置
  7. java 解锁关闭文件占用_程序员:Java文件锁定、解锁和其它NIO操作
  8. 相机模型与标定(十一)--LMEDS,M估计,RANSAC估计对比
  9. php的json_encode第二个参数学习及应用
  10. Maven压缩插件YUI Compressor使用介绍
  11. HD2500显卡驱动linux,Intel HD Graphics 4000/2500集成显卡驱动
  12. 【笔记】FFC 20624 Winter 09的mil与mm显示转换
  13. 微信小程序实现车牌号录入
  14. 牛客网 D-图图(广搜)
  15. play框架在idea开发工具上的简单配置
  16. 2019中国互联网300强
  17. 一位卖家对淘宝查杀虚假交易痛讼!
  18. 关于数据安全及保密(基于大数据板块的整理)
  19. 计算机网络----宽带速度kbps、KB、Mbps
  20. 主流深度学习GPU云平台租赁价格比较表

热门文章

  1. USB 3.0协议理解
  2. 【C++】命令行方式获取主板序列号
  3. 软件设计——蚂蚁采购配送系统
  4. 什么是主成分分析?经典案例解析变量降维
  5. 排序算法:冒泡排序(代码优化)
  6. (PD)PowerDesigner设计表时显示注释列Comment,Columns中没有Comment的解决办法(关联MySQL)
  7. 转载:机器视觉中使用深度学习所面临的对抗攻击——Survey(下)
  8. 使用淘宝助理要压缩一下数据库用的是sqlite作数据库的,
  9. android GPS 应用
  10. 连续潮流的理论与编程