demo_httpx_async.py 403 B

123456789101112131415161718
  1. # -*- coding: utf-8 -*-
  2. import httpx
  3. import asyncio
  4. async def async_get_example():
  5. async with httpx.AsyncClient() as client:
  6. response = await client.get('https://httpbin.org/get')
  7. print(f"Status Code: {response.status_code}")
  8. print(f"Response Content: {response.text}")
  9. async def main():
  10. await async_get_example()
  11. if __name__ == "__main__":
  12. asyncio.run(main())