request.py 文件源码

python
阅读 35 收藏 0 点赞 0 评论 0

项目:Requester 作者: kylebebak 项目源码 文件源码
def show_options(self, url, view):
        """Send options request to `url` and display results in pop-up.
        """
        res = options(url, timeout=3)
        if not res.ok:
            return
        names = ['Allow', 'Access-Control-Allow-Methods', 'Access-Control-Max-Age']
        headers = [res.headers.get(name, None) for name in names]
        items = '\n'.join('<li>{}: {}</li>'.format(n, h) for n, h in zip(names, headers) if h)
        content = '<h2>OPTIONS: {}</h2>\n<ul>{}</ul>'.format(url, items)
        try:
            json_dict = res.json()
        except:
            pass
        else:
            content = '{}\n<pre><code>{}</pre></code>'.format(
                content, json.dumps(json_dict, sort_keys=True, indent=2, separators=(',', ': '))
            )

        view.show_popup(content, max_width=700, max_height=500)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号