0
async def index(request):
    async with aiohttp.ClientSession() as client:
        data=await(email_verification(client))


        await client.post('http://127.0.0.1:8000/acc/signup',data=data)



async def email_verification(client):
    async with client.get('http://www.mocky.io/v2/5c18dfb62f00005b00af1241') as resp:

        return await(resp.json())

但是每当我尝试访问该网址时,我都会收到此错误

   await resp.prepare(request)
AttributeError: 'NoneType' object has no attribute 'prepare'

我什至无法理解问题是什么以及这个 resp.prepare 来自哪里

4

1 回答 1

2

Web-handler 应该返回一个响应对象,而不是 None。

固定代码是:

async def index(request):
    async with aiohttp.ClientSession() as client:
        data=await(email_verification(client))
        await client.post('http://127.0.0.1:8000/acc/signup',data=data)
    return web.Response(text="OK")

async def email_verification(client):
    async with client.get('http://www.mocky.io/v2/5c18dfb62f00005b00af1241') as resp:
        return await(resp.json())
于 2018-12-19T08:31:23.390 回答