test_vhosts.py 文件源码

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

项目:sanic 作者: channelcat 项目源码 文件源码
def test_vhosts_with_defaults():
    app = Sanic('test_vhosts')

    @app.route('/', host="hello.com")
    async def handler(request):
        return text("Hello, world!")

    @app.route('/')
    async def handler(request):
        return text("default")

    headers = {"Host": "hello.com"}
    request, response = app.test_client.get('/', headers=headers)
    assert response.text == "Hello, world!"

    request, response = app.test_client.get('/')
    assert response.text == "default"
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号