common.py 文件源码

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

项目:icfpc2016-judge 作者: icfpc2016 项目源码 文件源码
def _request(method, path, type, **kwargs):
    url = 'http://localhost:8000%s' % path
    res = method(url, **kwargs)
    res.raise_for_status()
    if type == 'html':
        assert 'text/html' in res.headers['Content-Type']
        doc = bs4.BeautifulSoup(res.text, 'html5lib')
    elif type == 'text':
        assert 'text/plain' in res.headers['Content-Type']
        doc = res.text
    elif type == 'json':
        assert ('application/json' in res.headers['Content-Type'] or
                'text/plain' in res.headers['Content-Type'])
        doc = ujson.loads(res.text)
    else:
        assert False, type
    return (res, doc)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号