open:aiohttp

aiohttp

@router.get("/")
async def products_get(request: Request):
    url = "https://YOUR_DOMAIN/products"

    async with aiohttp.ClientSession() as client:
        resp = await client.get(url)
        text = await resp.text()
        return Response(text, status_code=resp.status, headers=resp.headers)


@router.get("/{product_id}")
async def product_get(product_id: int, request: Request):
    url = f"https://YOUR_DOMAIN/products/{product_id}"

    resp = await aiohttp.ClientSession().get(url)
    text = await resp.text()
    return Response(text, status_code=resp.status, headers=resp.headers)


  • open/aiohttp.txt
  • 마지막으로 수정됨: 2021/12/21 06:07
  • 저자 127.0.0.1